Sha256: 5a2fe176faa89c193fd999795fc7aac8d2df4097516d8e15dfbed99a176c2b06

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 Bytes

Contents

module ExpressTemplates
  module Compiler
    def compile(template_or_src=nil, &block)
      _, src = _normalize(template_or_src)

        # local_assigns = {} if !defined?(local_assigns)
        # merged_assigns = assigns.merge(template_virtual_path: @virtual_path)
        #                         .merge(local_assigns)
      # The following must be one-line otherwise we lose accurate
      # line reporting on the stack.
      %Q{Arbre::Context.new(assigns.merge(template_virtual_path: @virtual_path).merge(defined?(local_assigns) ? local_assigns : {}), self) { #{src || block.source_body} }.to_s}
    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

2 entries across 2 versions & 1 rubygems

Version Path
express_templates-0.11.20 lib/express_templates/compiler.rb
express_templates-0.11.20.rc1 lib/express_templates/compiler.rb