class GlimHAMLSupport::HAMLLayout

Public Class Methods

new(site) click to toggle source
# File glim-haml-converter.rb, line 40
def initialize(site)
  @site  = site
  @cache = {}
end

Public Instance Methods

find_layout(name) click to toggle source
# File glim-haml-converter.rb, line 45
def find_layout(name)
  unless name.nil? || @cache.has_key?(name)
    path = File.join(@site.layouts_dir, name + '.haml')
    @cache[name] = if File.exists?(path)
      Glim::FileItem.new(@site, path)
    end
  end
  @cache[name]
end
transform(content, page, options) click to toggle source
Calls superclass method
# File glim-haml-converter.rb, line 55
def transform(content, page, options)
  layout = page.data['layout']
  if find_layout(layout)
    while layout_file = find_layout(layout)
      engine  = Haml::Engine.new(layout_file.content('liquid'), { :escape_attrs => :once })
      content = engine.render(ExposeLiquidFilters.new(@site, page), :content => content, :page => ExposeLiquidGetterAPI.new(page), :site => ExposeLiquidGetterAPI.new(@site))
      layout  = layout_file.data['layout']
    end
    content
  else
    super
  end
end