Sha256: 9c59e2a8b33013ee5168f3f240ba1a0d89270d38aed7dc54ec13937b89ff33e7

Contents?: true

Size: 566 Bytes

Versions: 1

Compression:

Stored size: 566 Bytes

Contents

module ExpressTemplates
  module Renderer
    # render accepts source or block, expands to macros
    # compiles the resulting macros 
    # and then evaluates the resulting string of ruby in the context provided
    def render context=nil, template_source=nil, &block
      expander = ExpressTemplates::Expander.new(nil)
      expanded_template = if block
        (expander.expand(&block).map(&:compile).join(';'))
      else
        expander.expand(template_source).map(&:compile).join(";")
      end
      context.instance_eval expanded_template
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
express_templates-0.2.0 lib/express_templates/renderer.rb