Files changed (4)
<p class="extract">In Dragonfly, templates are files that have newLISP code embedded in them. This code is evaluated server-side, generating a final document that's presented to visitors.</p>
+ Templates can be anything, but usually they're html files with newLISP code embedded in them. When you download Dragonfly, take a look at the files in <span class="code">example-site/views</span>, those are all templates, but they're also referred to as <b>views</b>.
+ The term "view" comes from the V in MVC (<a href="http://en.wikipedia.org/wiki/Model–view–controller">model-view-controller</a>), a paradigm that Dragonfly follows only loosely (notably missing the 'model' aspect).
+ Views are typically used to represent the data of a <i>model</i>, but Dragonfly doesn't really care to enforce this (although you are certainly welcome to). In this document the term 'view' will be used to refer to templates in the directory specified by <span class="code">DF:VIEWS_PATH</span>.
+ <span class="code">Route.Static</span> (one of the <%(link_to "default views" "dragonfly_routes")%>) contains, by default, two request transformations for handling views:
+ <p>All of the files handled by <span class="code">Route.Static</span> eventually get passed through the function <span class="code">eval-template</span>, which searches for any newLISP code between <span class="code">OPEN_TAG</span> and <span class="code">CLOSE_TAG</span> and evaluates it.</p>
+ By default, the <span class="code">OPEN_TAG</span> is <span class="code"><%</span> and the <span class="code">CLOSE_TAG</span> is <span class="code">%></span>. Let's say we want to create an HTML file that displays the current time on the server, we might go about it like this:
+ That's because evaluated expressions do not output anything unless they call <span class="code">print</span> or <span class="code">println</span>. We can fix it by rewriting it like so:
+ You can append an equals sign after the <span class="code">OPEN_TAG</span> to achieve the same result in fewer keystrokes:
+ <p class="info"><b>INFORMATION</b><br/>You can use all functions from newLISP and Dragonfly (<%(link_to "api" "dragonfly_api")%>), as well as functions provided by <%(link_to "plugins" "dragonfly_plugins")%>.</p>
+ Below is a list of configuration parameters that you'll find in <b>config.lsp</b> related to templates.
- <p>Put Your function call inside our open and close brackets and there You go! That will display some stats about rendering time and memory consumption.</p>
- <p class="info"><b>INFORMATION</b><br/>You can use all functions from newLISP and Dragonfly. Additionally You may write Your own functions inside a plugin and just put the file into the "plugins-active" directory.</p>
- those who want this Dragonfly provides explicit support through the 'display-partial' function:</p>