Class: Handlebars::Context
- Inherits:
-
Object
- Object
- Handlebars::Context
- Defined in:
- lib/handlebars/context.rb
Class Attribute Summary collapse
-
.current ⇒ Object
Returns the value of attribute current.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #compile(*args) ⇒ Object
- #handlebars ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #partial_missing(&fn) ⇒ Object
- #precompile(*args) ⇒ Object
- #register_helper(name, &fn) ⇒ Object
- #register_partial(name, content) ⇒ Object
- #runtime ⇒ Object
Constructor Details
#initialize ⇒ Context
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 = .partials = Handlebars::Partials.new end |
Class Attribute Details
.current ⇒ Object
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, .compile(*args)) end |
#handlebars ⇒ Object
35 36 37 |
# File 'lib/handlebars/context.rb', line 35 def @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) .precompile(*args) end |
#register_helper(name, &fn) ⇒ Object
23 24 25 |
# File 'lib/handlebars/context.rb', line 23 def register_helper(name, &fn) .registerHelper(name, fn) end |
#register_partial(name, content) ⇒ Object
27 28 29 |
# File 'lib/handlebars/context.rb', line 27 def register_partial(name, content) .registerPartial(name, content) end |
#runtime ⇒ Object
39 40 41 |
# File 'lib/handlebars/context.rb', line 39 def runtime @js.runtime end |