Sha256: 5050d8d8db246bee9502d5fc31f6f22fda4fb9deb325ff6bf29c502e25057ce6
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
# encoding: utf-8 require "template-inheritance" require "padrino-core/application/rendering" # TODO: It'd be nice to share the logger. module TemplateInheritance class Template attr_accessor :padrino_views_directory def instantiate_supertemplate supertemplate = self.class.new(self.supertemplate, self.scope) supertemplate.padrino_views_directory = self.padrino_views_directory supertemplate.blocks = self.blocks supertemplate end end module TemplateHelpers alias_method :_normalize_template_path, :normalize_template_path def normalize_template_path(path) full_path = File.join(template.padrino_views_directory, path) _normalize_template_path(full_path) end end end module TemplateInheritance::Rendering def self.registered(app) app.helpers(self) app.register(Padrino::Rendering) end # TODO: support options for Haml. # NOTE: block does nothing, it's for builder etc, not useful for Haml. # FIXME: locals doesn't work because we don't get them from Padrino. # TODO: no support for render(_, data) i. e. render { :a => 1, :b => 2, :c => 3 } include Module.new { def render(_, path, options, locals, &block) base_dir = options[:views] || settings.views || "./views" fullpath = File.join(base_dir, path.to_s) template = TemplateInheritance::Template.new(fullpath, self) template.padrino_views_directory = base_dir options && options.delete(:layout_engine) options && options.delete(:layout) template.render(locals) end } end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
template-inheritance-0.3.1 | lib/template-inheritance/adapters/padrino.rb |