Sha256: d901e7c75ad644b6339c1e6625b663045898cc0cdc090ac0c4c37a98b66ff55e

Contents?: true

Size: 931 Bytes

Versions: 2

Compression:

Stored size: 931 Bytes

Contents

module ExpressTemplates
  module Compiler
    def compile(template_or_src=nil, &block)
      template, 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.19 lib/express_templates/compiler.rb
express_templates-0.11.18 lib/express_templates/compiler.rb