I’ve seen how to use embed HTML in a skin file to provide a global layout, but how can I use a text file for my global layout? I really want to avoid putting markup in my source code.
Thanks!
(1 attempts)
Kashia answered:
Template based elements... how about reading from a file.. and hiding the details...
Just brainstorming:
module TemplateBasedElement setting :template_dir, :default => 'element_templates', :doc => 'Template directory for Elements/Skins.' setting :template_ext, :default => '.xhtml' def self.included_with_parameters(base, options) file = File.join template_dir, base.to_s.pathize + template_ext if File.exists? file str = File.read file base.module_eval <<-EOE, __FILE__, __LINE__ def render_template #{str} end alias :render, :render_template EOE end end end class Skin < Nitro::Element is TemplateBasedElement end
The template you had to change then would be: element_templates/skin.xhtml
That's the basic idea anyway, never tried it, so I'm not sure if it actually works. (something like that should be built into Nitro....)