Class: Sinatra::JstPages::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/furnace-xray/lib/jst_pages.rb

Direct Known Subclasses

EcoEngine, HamlEngine, JadeEngine, MustacheEngine

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Engine

Returns a new instance of Engine.



181
182
183
# File 'lib/furnace-xray/lib/jst_pages.rb', line 181

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

### file [attribute] The string path of the template file.



180
181
182
# File 'lib/furnace-xray/lib/jst_pages.rb', line 180

def file
  @file
end

Instance Method Details

#contentsObject

### contents [method] Returns the contents of the template file as a string.



187
188
189
# File 'lib/furnace-xray/lib/jst_pages.rb', line 187

def contents
  File.read(@file)
end

#functionObject

### function [method] The JavaScript function to invoke on the precompile’d object.

What this returns should, in JavaScript, return a function that can be called with an object hash of the params to be passed onto the template.



196
197
198
# File 'lib/furnace-xray/lib/jst_pages.rb', line 196

def function
  "_.template(#{contents.inspect})"
end