Vagabond asked:

How do I use templates for Elements?

I don’t want all my Elements in ruby files, I want them in xhtml templates, how can I do this?

(1 attempts)

Vagabond answered:

Nitro can compile templates into Element classes, but you need to get the paths right. Nitro by default looks for the 'elements' folder in Template.root, then the project root, then in src. If you want to override the path, you need to set Nitro::Element.templateroot to some path, and THEN call Nitro::Element.compiletemplate_elements to recompile the templates.

compiletemplateelements does not re-check the value of Template.root, so simply changing that variable before recompiling the templates is not sufficent (maybe it SHOULD re-check the value though...)

require 'nitro'
Template.root = 'templates'
Nitro::Element.template_root = 'templates/elements'

Rating: 5