Creating dynamic pages
nanoc is a tool aimed at generating static pages, but that does not mean it prevents you from creating dynamic pages. For example, it is possible to create a contact page with a form, which sends a mail when submitted.
Using PHP
If your web hosting service does not offer support for running Ruby, you can always fall back to good old fashioned PHP. To create a PHP page, change the extension to "php", like this:
extension: "php"
Then, you can simply put your PHP code in the page. nanoc will write an index.php file that contains the PHP code. (If nanoc already created an index.html file before, you'll probably want to remove it.)
Using embedded Ruby
You can use the PHP technique mentioned above for embedded Ruby as well. Change the file extension to "rhtml", and put your embedded Ruby code on the page. (You may also need to set up your web server to handle .rhtml files correctly, if you haven't done so before.)
If your page's filters contains eruby, though, things get a bit trickier. In that case, all embedded Ruby code will be executed when compiling the page, which is likely not what you want.
There is a neat trick if you use ERB (It doesn't work with Erubis, but since ERB is the default it should probably not be an issue). If you add a second % to the eRuby tag, it will not be executed, and will instead be outputted with one % less.
For example:
ERB.new('<%= "foo" %>').result
will return
'foo'
(obviously), and
ERB.new('<%%= "foo" %>').result
will return
'<%= "foo" %>'
You can use this trick to make sure that the code is executed on the server, and not executed by nanoc.
