Sha256: 07a5583272924678216e30d0aa168598d71cf8fee75c595f62a028c1e6a4f3fa

Contents?: true

Size: 422 Bytes

Versions: 8

Compression:

Stored size: 422 Bytes

Contents

module Gratan
  module TemplateHelper
    def include_template(template_name, context = {})
      tmplt = @context.templates[template_name.to_s]

      unless tmplt
        raise "Template `#{template_name}` is not defined"
      end

      context_orig = @context
      @context = @context.merge(context)
      instance_eval(&tmplt)
      @context = context_orig
    end

    def context
      @context
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gratan-0.3.2 lib/gratan/template_helper.rb
gratan-0.3.1 lib/gratan/template_helper.rb
gratan-0.3.1.beta4 lib/gratan/template_helper.rb
gratan-0.3.1.beta3 lib/gratan/template_helper.rb
gratan-0.3.1.beta2 lib/gratan/template_helper.rb
gratan-0.3.1.beta lib/gratan/template_helper.rb
gratan-0.3.0 lib/gratan/template_helper.rb
gratan-0.3.0.beta lib/gratan/template_helper.rb