Class: Hamlbars::Template
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Hamlbars::Template
- Includes:
- Ext::RailsHelper
- Defined in:
- lib/hamlbars/template.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#evaluate(scope, locals, &block) ⇒ Object
Uses Haml to render the template into an HTML string, then wraps it in the neccessary JavaScript to serve to the client.
- #initialize_engine ⇒ Object
- #prepare ⇒ Object
Methods included from Ext::RailsHelper
Class Method Details
.engine_initialized? ⇒ Boolean
11 12 13 |
# File 'lib/hamlbars/template.rb', line 11 def self.engine_initialized? defined? ::Haml::Engine end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
Uses Haml to render the template into an HTML string, then wraps it in the neccessary JavaScript to serve to the client.
26 27 28 29 30 31 32 |
# File 'lib/hamlbars/template.rb', line 26 def evaluate(scope, locals, &block) if @engine.respond_to?(:precompiled_method_return_value, true) super(scope, locals, &block) else @engine.render(scope, locals, &block) end end |
#initialize_engine ⇒ Object
15 16 17 |
# File 'lib/hamlbars/template.rb', line 15 def initialize_engine require_template_library 'haml' end |
#prepare ⇒ Object
19 20 21 22 |
# File 'lib/hamlbars/template.rb', line 19 def prepare = @options.merge(:filename => eval_file, :line => line) @engine = ::Haml::Engine.new(data, ) end |