Class: Sinatra::JstPages::Engine
- Inherits:
-
Object
- Object
- Sinatra::JstPages::Engine
- Defined in:
- lib/sinatra/jstpages.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
### file [attribute] The string path of the template file.
Instance Method Summary collapse
-
#contents ⇒ Object
### contents [method] Returns the contents of the template file as a string.
-
#function ⇒ Object
### function [method] The JavaScript function to invoke on the precompile’d object.
-
#initialize(file) ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
#initialize(file) ⇒ Engine
Returns a new instance of Engine.
185 186 187 |
# File 'lib/sinatra/jstpages.rb', line 185 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
### file [attribute] The string path of the template file.
184 185 186 |
# File 'lib/sinatra/jstpages.rb', line 184 def file @file end |
Instance Method Details
#contents ⇒ Object
### contents [method] Returns the contents of the template file as a string.
191 192 193 |
# File 'lib/sinatra/jstpages.rb', line 191 def contents File.read(@file) end |
#function ⇒ Object
### 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.
200 201 202 |
# File 'lib/sinatra/jstpages.rb', line 200 def function "_.template(#{contents.inspect})" end |