0
cattr_reader :theme_path, :default_assigns
0
cattr_accessor :multi_sites_enabled, :cache_sweeper_tracing
0
+ # @@template_handlers = HashWithIndifferentAccess.new if @@template_handlers.nil?
0
+ @@template_handlers = {}
0
+ # Register a class that knows how to handle template files with the given
0
+ # extension. This can be used to implement new template types.
0
+ # The constructor for the class must take a Site instance
0
+ # as a parameter, and the class must implement a #render method that
0
+ # has the following signature
0
+ # def render(section, layout, template, assigns ={}, controller = nil)
0
+ # and return the rendered template as a string.
0
+ def self.register_template_handler(extension, klass)
0
+ @@template_handlers[extension] = klass
0
+ register_template_handler(".liquid", Mephisto::Liquid::LiquidTemplate)
0
+ @@template_handlers.keys
0
has_many :sections, :order => "position" do
0
- def
render_liquid_for(section, template_type, assigns = {}, controller = nil)
0
+ def
call_render(section, template_type, assigns = {}, controller = nil)
0
assigns.update('site' => to_liquid(section), 'mode' => template_type)
0
assigns.update(default_assigns) unless default_assigns.empty?
0
- parse_inner_template(set_content_template(section, template_type), assigns, controller)
0
- parse_template(set_layout_template(section, template_type), assigns, controller)
0
+ template = set_content_template(section, template_type)
0
+ layout = set_layout_template(section, template_type)
0
+ handler = @@template_handlers[theme.extension] || @@template_handlers[".liquid"]
0
+ handler.new(self).render(section, layout, template, assigns, controller)
0
def to_liquid(current_section = nil)
0
SiteDrop.new self, current_section
0
+#need non protected method for ErbTemplate - psq
0
+ def find_preferred_template(template_type, custom_template)
0
+ preferred = templates.find_preferred(template_type, custom_template)
0
+ return preferred if preferred && preferred.file?
0
+ raise MissingTemplateError.new(template_type, templates.collect_templates(template_type, custom_template).collect(&:basename))
0
def cached_log_message_for(log_message, pages)
0
pages.inject([log_message, "Expiring #{pages.size} page(s)"]) { |msg, p| msg << " - #{p.url}" }.join("\n")
0
find_preferred_template(:layout, layout_template)
0
- def find_preferred_template(template_type, custom_template)
0
- preferred = templates.find_preferred(template_type, custom_template)
0
- return preferred if preferred && preferred.file?
0
- raise MissingTemplateError.new(template_type, templates.collect_templates(template_type, custom_template).collect(&:basename))
0
- def parse_template(template, assigns, controller)
0
- # give the include tag access to files in the site's fragments directory
0
- Liquid::Template.file_system = Liquid::LocalFileSystem.new(File.join(theme.path, 'templates'))
0
- tmpl = Liquid::Template.parse(template.read.to_s)
0
- returning tmpl.render(assigns, :registers => {:controller => controller}) do |result|
0
- yield tmpl, result if block_given?
0
- def parse_inner_template(template, assigns, controller)
0
- parse_template(template, assigns, controller) do |tmpl, result|
0
- # Liquid::Template takes a copy of the assigns.
0
- # merge any new values in to the assigns and pass them to the layout
0
- tmpl.assigns.each { |k, v| assigns[k] = v } if tmpl.respond_to?(:assigns)
0
- assigns['content_for_layout'] = result
Comments
No one has commented yet.