Let’s make a controller named article:
art draw controller article show edit
show and edit are the name of methods for the controller named article.
This will generate both a controller and a 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
These three files are generated:
app/controllers/article.scm app/views/article/show.html.tpl app/views/article/edit.html.tpl
Based on this, the controller article will have two methods mapped to the URL rule, show and edit. As part of the view component. An HTML template is generated for each method. For the show method for example, the view file show.html.tpl is created. For the controller component, you get a show method handler, as:
(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, you’re free to use or not use these templates. If you want to use the view template, just uncomment the last line (view-render "show")
.
NOTE: The views template generated by MVC will defaultly announce FreeJS. The reason was well explained in The Javascript Trap. It’s optional, you may remove it with your free will, but I put it there in the hope that you can support free software with us.
For more detail about template in Views, please see Layouts and Rendering in GNU Artanis.