Sha256: cf2ee9058219a16fb200e041228dd6bd0c9ea64f5b479d3aa979d6d9940d6274

Contents?: true

Size: 780 Bytes

Versions: 7

Compression:

Stored size: 780 Bytes

Contents

module ExpressTemplates
  module Compiler
    def compile(template_or_src=nil, &block)
      template, src = _normalize(template_or_src)
      %Q{
        assigns.merge!(template_virtual_path: @virtual_path)
        if defined?(local_assigns)
          Arbre::Context.new(assigns.merge(local_assigns), self) { #{src || block.source_body} }.to_s
        else
          Arbre::Context.new(assigns, self) { #{src || block.source_body} }.to_s
        end
      }
    end

    private
      def _normalize(template_or_src)
        template, src = nil, nil
        if template_or_src.respond_to?(:source)
          template = template_or_src
          src = template_or_src.source
        else
          src = template_or_src
        end
        return template, src
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
express_templates-0.11.17 lib/express_templates/compiler.rb
express_templates-0.11.16 lib/express_templates/compiler.rb
express_templates-0.11.16.rc1 lib/express_templates/compiler.rb
express_templates-0.11.15 lib/express_templates/compiler.rb
express_templates-0.11.14 lib/express_templates/compiler.rb
express_templates-0.11.13 lib/express_templates/compiler.rb
express_templates-0.11.11 lib/express_templates/compiler.rb