Next: , Up: MVC   [Contents]

11.1 Controllers/Views

When you run it to generate a controller named article:

art draw controller article show edit

show and edit are the name of methods for the controller named article.

And it’ll generate both controller and view for article:

drawing    controller article
working    Controllers `article.scm'
create     app/controllers/article.scm
working    Views `article'
create     app/views/article/show.html.tpl
create     app/views/article/edit.html.tpl

As you may see, there’re three files were generated:


This means the controller article has two methods mapped to URL rule named show and edit. And view component will generate HTML template for each method, say, show.html.tpl. For example, the controller article generate show method handler automatically:

(article-define show
                (lambda (rc)
                  "<h1>This is article#show</h1><p>Find me in app/views/article/show.html.tpl</p>"
                  ;; TODO: add controller method `show'
                  ;; uncomment this line if you want to render view from template
                  ;; (view-render "show")

Of course, it depends on you whether to use these template. If you want to use view template, just uncomment the last line (view-render "show").

For more detail about template in Views, please see Layouts and Rendering in GNU Artanis.