Sha256: ba5697cdb18b884f16947cbac3e63748f9db11285e7c767828cc635896b81e65

Contents?: true

Size: 955 Bytes

Versions: 51

Compression:

Stored size: 955 Bytes

Contents

module Dugway
  class Template
    attr_reader :name

    def initialize(name)
      @name = name
    end

    def content
      Dugway.theme.file_content(name)
    end
    
    def content_type
      Rack::Mime.mime_type(extension)
    end
    
    def extension
      File.extname(name)
    end
    
    def html?
      extension == '.html'
    end
    
    def standalone_html?
      html? && !!(content =~ /\{\{\s*head_content\s*\}\}/)
    end
    
    def render(request, variables={})
      if html?
        liquifier = Liquifier.new(request)
        content_to_render = variables[:page] && variables[:page]['content'] || content
        rendered_content = liquifier.render(content_to_render, variables)
        
        if standalone_html?
          rendered_content
        else
          liquifier.render(Dugway.theme.layout, variables.update(:page_content => rendered_content))
        end
      else
        content
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
dugway-0.11.2 lib/dugway/template.rb
dugway-0.11.1 lib/dugway/template.rb
dugway-0.11.0 lib/dugway/template.rb
dugway-0.10.5 lib/dugway/template.rb
dugway-0.10.4 lib/dugway/template.rb
dugway-0.10.3 lib/dugway/template.rb
dugway-0.10.2 lib/dugway/template.rb
dugway-0.10.1 lib/dugway/template.rb
dugway-0.10.0 lib/dugway/template.rb
dugway-0.9.0 lib/dugway/template.rb
dugway-0.8.4 lib/dugway/template.rb
dugway-0.8.3 lib/dugway/template.rb
dugway-0.8.2 lib/dugway/template.rb
dugway-0.8.1 lib/dugway/template.rb
dugway-0.8.0 lib/dugway/template.rb
dugway-0.7.1 lib/dugway/template.rb
dugway-0.7.0 lib/dugway/template.rb
dugway-0.6.7 lib/dugway/template.rb
dugway-0.6.6 lib/dugway/template.rb
dugway-0.6.5 lib/dugway/template.rb