module ExpressTemplates::Compiler

Public Instance Methods

compile(template_or_src=nil, &block) click to toggle source
# File lib/express_templates/compiler.rb, line 3
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 Instance Methods

_normalize(template_or_src) click to toggle source
# File lib/express_templates/compiler.rb, line 15
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