Class: RubyHamlJs::Template
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- RubyHamlJs::Template
- Defined in:
- lib/ruby-haml-js/template.rb
Class Attribute Summary collapse
-
.custom_escape ⇒ Object
Returns the value of attribute custom_escape.
-
.haml_path ⇒ Object
Returns the value of attribute haml_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#evaluate(scope, locals, &block) ⇒ Object
Compiles the template using HAML-JS.
- #initialize_engine ⇒ Object
- #prepare ⇒ Object
Class Attribute Details
.custom_escape ⇒ Object
Returns the value of attribute custom_escape.
52 53 54 |
# File 'lib/ruby-haml-js/template.rb', line 52 def custom_escape @custom_escape end |
.haml_path ⇒ Object
Returns the value of attribute haml_path.
53 54 55 |
# File 'lib/ruby-haml-js/template.rb', line 53 def haml_path @haml_path end |
Class Method Details
.engine_initialized? ⇒ Boolean
7 8 9 |
# File 'lib/ruby-haml-js/template.rb', line 7 def self.engine_initialized? defined? ::ExecJS end |
.haml_source ⇒ Object
55 56 57 58 59 |
# File 'lib/ruby-haml-js/template.rb', line 55 def haml_source # Haml source is an asset @haml_path = File.('../../../vendor/assets/javascripts/haml.js', __FILE__) if @haml_path.nil? @haml_source ||= IO.read @haml_path end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
Compiles the template using HAML-JS
Returns a JS function definition String. The result should be assigned to a JS variable.
# => "function(data) { ... }"
24 25 26 |
# File 'lib/ruby-haml-js/template.rb', line 24 def evaluate(scope, locals, &block) compile_to_function end |
#initialize_engine ⇒ Object
11 12 13 |
# File 'lib/ruby-haml-js/template.rb', line 11 def initialize_engine require_template_library 'execjs' end |
#prepare ⇒ Object
15 16 |
# File 'lib/ruby-haml-js/template.rb', line 15 def prepare end |