Class: RubyHamlJs::Template

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/ruby-haml-js/template.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.custom_escapeObject

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_pathObject

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

Returns:

  • (Boolean)


7
8
9
# File 'lib/ruby-haml-js/template.rb', line 7

def self.engine_initialized?
  defined? ::ExecJS
end

.haml_sourceObject



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.expand_path('../../../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_engineObject



11
12
13
# File 'lib/ruby-haml-js/template.rb', line 11

def initialize_engine
  require_template_library 'execjs'
end

#prepareObject



15
16
# File 'lib/ruby-haml-js/template.rb', line 15

def prepare
end