Sha256: 8908aa473b8b89994251fe6186edcb8c11b89fa58318495477414d8529b19177

Contents?: true

Size: 706 Bytes

Versions: 7

Compression:

Stored size: 706 Bytes

Contents

require File.dirname(__FILE__) + "/helpers/capture"
require File.dirname(__FILE__) + "/helpers/partial"

module Roger
  class Template
    # The context that is passed to all templates
    class TemplateContext
      include Helpers::Capture
      include Helpers::Partial

      def initialize(template, env = {})
        @_template = template
        @_env = env
      end

      # The current Roger::Template in use
      def template
        @_template
      end

      # Access to the front-matter of the document (if any)
      def document
        @_data ||= OpenStruct.new(template.data)
      end

      # The current environment variables.
      def env
        @_env
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
roger-1.4.6 lib/roger/template/template_context.rb
roger-1.4.5 lib/roger/template/template_context.rb
roger-1.4.4 lib/roger/template/template_context.rb
roger-1.4.3 lib/roger/template/template_context.rb
roger-1.4.2 lib/roger/template/template_context.rb
roger-1.4.1 lib/roger/template/template_context.rb
roger-1.4.0 lib/roger/template/template_context.rb