Class: Skim::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/skim/template.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.skim_srcObject



30
31
32
33
# File 'lib/skim/template.rb', line 30

def self.skim_src
  @@skim_src ||=
    File.read(File.expand_path("../../../vendor/assets/javascripts/skim.js.coffee", __FILE__))
end

Instance Method Details

#coffee_script_srcObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/skim/template.rb', line 9

def coffee_script_src
  engine = self.class.build_engine({
    :streaming => false, # Overwrite option: No streaming support in Tilt
    :file => eval_file,
    :indent => 2 }, options)
  <<SRC
#{self.class.skim_src unless engine.options[:use_asset]}
return (context = {}) ->
  Skim.withContext.call {}, context, ->
#{engine.call(data)}
SRC
end

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



26
27
28
# File 'lib/skim/template.rb', line 26

def evaluate(scope, locals, &block)
  precompiled_template
end

#prepareObject



22
23
24
# File 'lib/skim/template.rb', line 22

def prepare
  @src = CoffeeScript.compile(coffee_script_src)
end