Module: Sinatra::JstPages

Defined in:
lib/sinatra/jstpages.rb,
lib/sinatra/jstpages.rb

Overview

JstPages::Engine [class]

A template engine.

Adding support for new template engines

You will need to subclass Engine, override at least the function method, then use JstPages.register.

This example will register .jst.my files to a new engine that uses My.compile.

module Sinatra::JstPages
  class MyEngine < Engine
    def function() "My.compile(#{contents.inspect})"; end
  end

  register 'my', MyEngine
end

Defined Under Namespace

Modules: ClassMethods, Helpers Classes: EcoEngine, Engine, HamlEngine, JadeEngine

Class Method Summary collapse

Class Method Details

.mappingsObject

Returns a hash to determine which engine is mapped onto a given extension.



105
106
107
# File 'lib/sinatra/jstpages.rb', line 105

def self.mappings
  @mappings ||= Hash.new
end

.register(ext, engine) ⇒ Object



109
110
111
# File 'lib/sinatra/jstpages.rb', line 109

def self.register(ext, engine)
  mappings[ext] = engine
end

.registered(app) ⇒ Object



99
100
101
102
# File 'lib/sinatra/jstpages.rb', line 99

def self.registered(app)
  app.extend ClassMethods
  app.helpers Helpers
end