class Emblem::Rails::Template

Public Instance Methods

evaluate(scope, locals, &block) click to toggle source
# File lib/emblem/rails/template.rb, line 10
def evaluate(scope, locals, &block)
  target = global_template_target(scope)
  raw = raw?(scope)

  template = data

  if configuration.precompile
    if raw
      template = precompile_emblem(template)
    else
      template = precompile_ember_emblem(template)
    end
  else
    if raw
      template = compile_emblem(data)
    else
      template = compile_ember_emblem(template)
    end
  end

  "#{target} = #{template}\n"
end

Private Instance Methods

compile_ember_emblem(string) click to toggle source
# File lib/emblem/rails/template.rb, line 47
def compile_ember_emblem(string)
  "Emblem.compile(Ember.Handlebars, #{indent(string).inspect});"
end
compile_emblem(string) click to toggle source
# File lib/emblem/rails/template.rb, line 39
def compile_emblem(string)
  "Handlebars.compile(#{indent(string).inspect});"
end
precompile_ember_emblem(string) click to toggle source
# File lib/emblem/rails/template.rb, line 51
def precompile_ember_emblem(string)
  Barber::Emblem::EmberFilePrecompiler.call(string)
end
precompile_emblem(string) click to toggle source
# File lib/emblem/rails/template.rb, line 43
def precompile_emblem(string)
  Barber::Emblem::FilePrecompiler.call(string)
end
raw?(scope) click to toggle source
# File lib/emblem/rails/template.rb, line 35
def raw?(scope)
  scope.pathname.to_s =~ /\.raw\.(emblem)/
end