Class: Ember::Appkit::Rails::Template

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/ember/appkit/rails/template.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_mime_typeObject


6
7
8
# File 'lib/ember/appkit/rails/template.rb', line 6

def self.default_mime_type
  'application/javascript'
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ember/appkit/rails/template.rb', line 12

def evaluate(scope, locals, &block)
  raw = handlebars?(scope)

  if raw
    template = data
  else
    template = mustache_to_handlebars(scope, data)
  end

  if configuration.precompile
    if raw
      template = precompile_handlebars(template)
    else
      template = precompile_ember_handlebars(template)
    end
  else
    if raw
      template = compile_handlebars(data)
    else
      template = compile_ember_handlebars(template)
    end
  end

  if configuration.output_type == :amd
    target = amd_template_target(scope)

    "define('#{target}', ['exports'], function(__exports__){ __exports__.default = #{template} });"
  else
    target = global_template_target(scope)

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

#prepareObject


10
# File 'lib/ember/appkit/rails/template.rb', line 10

def prepare; end