Sha256: b183bb13916904d39e85f53365d7496fd4d9017cb6319edfe922daf3a9e470a9

Contents?: true

Size: 428 Bytes

Versions: 6

Compression:

Stored size: 428 Bytes

Contents

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

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

      context_org = @context
      @context = @context.merge(context)
      instance_eval(&template)
      @context = context_org
    end

    def context
      @context
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
applb-0.1.5.beta1 lib/applb/template_helper.rb
applb-0.1.4 lib/applb/template_helper.rb
applb-0.1.3 lib/applb/template_helper.rb
applb-0.1.2 lib/applb/template_helper.rb
applb-0.1.1 lib/applb/template_helper.rb
applb-0.1.0 lib/applb/template_helper.rb