class Locomotive::Steam::Decorators::TemplateDecorator
Public Instance Methods
liquid_source()
click to toggle source
# File lib/locomotive/steam/decorators/template_decorator.rb, line 9 def liquid_source if respond_to?(:template_path) && template_path source_from_template_file else self.source.blank? ? source_in_default_locale : self.source end end
Private Instance Methods
render_haml(source, template_path)
click to toggle source
# File lib/locomotive/steam/decorators/template_decorator.rb, line 37 def render_haml(source, template_path) begin Haml::Engine.new(source, escape_attrs: false).render rescue Haml::SyntaxError => e raise Steam::RenderError.new(e, template_path, source) end end
source_from_template_file()
click to toggle source
# File lib/locomotive/steam/decorators/template_decorator.rb, line 23 def source_from_template_file source = File.read(template_path).force_encoding('utf-8') if match = source.match(FRONTMATTER_REGEXP) source = match[:template] end if template_path.ends_with?('.haml') render_haml(source, template_path) else source end end
source_in_default_locale()
click to toggle source
# File lib/locomotive/steam/decorators/template_decorator.rb, line 19 def source_in_default_locale self.__with_default_locale__ { self.source } end