Class: Mullet::Sinatra::Engine
- Inherits:
-
Object
- Object
- Mullet::Sinatra::Engine
- Defined in:
- lib/mullet/sinatra/engine.rb
Overview
Loads view classes and template files.
Instance Method Summary collapse
-
#get_template(view_name, options) ⇒ Object
Gets template.
-
#get_view_class(view_name, options) ⇒ Object
Gets view class.
-
#initialize ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
#initialize ⇒ Engine
Returns a new instance of Engine.
8 9 10 11 |
# File 'lib/mullet/sinatra/engine.rb', line 8 def initialize() @class_cache = Hash.new() @loader = Mullet::HTML::TemplateLoader.new(nil) end |
Instance Method Details
#get_template(view_name, options) ⇒ Object
Gets template.
20 21 22 23 24 |
# File 'lib/mullet/sinatra/engine.rb', line 20 def get_template(view_name, ) template_path = [:template_path] || [:views] @loader.template_path = template_path return @loader.load("#{view_name.to_s()}.html") end |
#get_view_class(view_name, options) ⇒ Object
Gets view class.
33 34 35 36 37 38 39 40 |
# File 'lib/mullet/sinatra/engine.rb', line 33 def get_view_class(view_name, ) view_class = @class_cache.fetch(view_name, nil) if view_class == nil view_class = find_class(view_name.to_s(), ) @class_cache.store(view_name, view_class) end return view_class end |