Class: MagLove::Tilt::JsTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- MagLove::Tilt::JsTemplate
- Defined in:
- lib/maglove/tilt/js_template.rb
Instance Method Summary collapse
Instance Method Details
#allows_script? ⇒ Boolean
30 31 32 |
# File 'lib/maglove/tilt/js_template.rb', line 30 def allows_script? false end |
#evaluate(scope, locals, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/maglove/tilt/js_template.rb', line 8 def evaluate(scope, locals, &block) # handle includes @data = @data.gsub(%r{^//=\srequire\s(.+)$}) do |match| path = Regexp.last_match[1] include_path = File.absolute_path(path, File.dirname(file)) # check if base path exists unless File.exist?(include_path) include_path = File.absolute_path(path, locals[:base_path]) end if File.exist?(include_path) include_template = ::Tilt.new(include_path) include_template.render(Object.new, locals) else raise "Path not found: #{include_path}" end end @output = @data end |
#prepare ⇒ Object
6 |
# File 'lib/maglove/tilt/js_template.rb', line 6 def prepare; end |