Class: Sinatra::JstPages::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/jstpages.rb

Direct Known Subclasses

EcoEngine, HamlEngine, JadeEngine

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fileObject (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

#contentsObject

### 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

#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.



200
201
202
# File 'lib/sinatra/jstpages.rb', line 200

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