Class: Handlebars::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/handlebars/context.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



7
8
9
10
11
12
13
# File 'lib/handlebars/context.rb', line 7

def initialize
  @js = CommonJS::Environment.new V8::Context.new, :path => [
    File.dirname(Handlebars::Source.bundled_path)
  ]

  @partials = handlebars.partials = Handlebars::Partials.new
end

Class Attribute Details

.currentObject

Returns the value of attribute current.



52
53
54
# File 'lib/handlebars/context.rb', line 52

def current
  @current
end

Instance Method Details

#[](key) ⇒ Object



47
48
49
# File 'lib/handlebars/context.rb', line 47

def [](key)
  data[key]
end

#[]=(key, value) ⇒ Object



43
44
45
# File 'lib/handlebars/context.rb', line 43

def []=(key, value)
  data[key] = value
end

#compile(*args) ⇒ Object



15
16
17
# File 'lib/handlebars/context.rb', line 15

def compile(*args)
  ::Handlebars::Template.new(self, handlebars.compile(*args))
end

#handlebarsObject



35
36
37
# File 'lib/handlebars/context.rb', line 35

def handlebars
  @js.require('handlebars')
end

#partial_missing(&fn) ⇒ Object



31
32
33
# File 'lib/handlebars/context.rb', line 31

def partial_missing(&fn)
  @partials.partial_missing = fn
end

#precompile(*args) ⇒ Object



19
20
21
# File 'lib/handlebars/context.rb', line 19

def precompile(*args)
  handlebars.precompile(*args)
end

#register_helper(name, &fn) ⇒ Object



23
24
25
# File 'lib/handlebars/context.rb', line 23

def register_helper(name, &fn)
  handlebars.registerHelper(name, fn)
end

#register_partial(name, content) ⇒ Object



27
28
29
# File 'lib/handlebars/context.rb', line 27

def register_partial(name, content)
  handlebars.registerPartial(name, content)
end

#runtimeObject



39
40
41
# File 'lib/handlebars/context.rb', line 39

def runtime
  @js.runtime
end