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
- #create_frame(data) ⇒ Object
- #handlebars ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #load_helper(path) ⇒ Object
- #load_helpers(helpers_pattern) ⇒ Object
- #partial_missing(&fn) ⇒ Object
- #precompile(*args) ⇒ Object
- #register_helper(name, &fn) ⇒ Object
- #register_partial(name, content) ⇒ Object
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
6 7 8 9 10 11 12 |
# File 'lib/handlebars/context.rb', line 6 def initialize @js = V8::Context.new @js['global'] = {} # there may be a more appropriate object to be used here @MHW @js.load(Handlebars::Source.bundled_path) @partials = .partials = Handlebars::Partials.new end |
Class Attribute Details
.current ⇒ Object
Returns the value of attribute current.
59 60 61 |
# File 'lib/handlebars/context.rb', line 59 def current @current end |
Instance Method Details
#[](key) ⇒ Object
54 55 56 |
# File 'lib/handlebars/context.rb', line 54 def [](key) data[key] end |
#[]=(key, value) ⇒ Object
50 51 52 |
# File 'lib/handlebars/context.rb', line 50 def []=(key, value) data[key] = value end |
#compile(*args) ⇒ Object
14 15 16 |
# File 'lib/handlebars/context.rb', line 14 def compile(*args) ::Handlebars::Template.new(self, .compile(*args)) end |
#create_frame(data) ⇒ Object
38 39 40 |
# File 'lib/handlebars/context.rb', line 38 def create_frame(data) .createFrame(data) end |
#handlebars ⇒ Object
46 47 48 |
# File 'lib/handlebars/context.rb', line 46 def @js.eval('Handlebars') end |
#load_helper(path) ⇒ Object
22 23 24 |
# File 'lib/handlebars/context.rb', line 22 def load_helper(path) @js.load(path) end |
#load_helpers(helpers_pattern) ⇒ Object
18 19 20 |
# File 'lib/handlebars/context.rb', line 18 def load_helpers(helpers_pattern) Dir[helpers_pattern].each{ |path| load_helper(path) } end |
#partial_missing(&fn) ⇒ Object
42 43 44 |
# File 'lib/handlebars/context.rb', line 42 def partial_missing(&fn) @partials.partial_missing = fn end |
#precompile(*args) ⇒ Object
26 27 28 |
# File 'lib/handlebars/context.rb', line 26 def precompile(*args) .precompile(*args) end |
#register_helper(name, &fn) ⇒ Object
30 31 32 |
# File 'lib/handlebars/context.rb', line 30 def register_helper(name, &fn) .registerHelper(name, fn) end |
#register_partial(name, content) ⇒ Object
34 35 36 |
# File 'lib/handlebars/context.rb', line 34 def register_partial(name, content) .registerPartial(name, content) end |