Class: Racket::Utils::Views::TemplateLocator
- Inherits:
-
Object
- Object
- Racket::Utils::Views::TemplateLocator
- Defined in:
- lib/racket/utils/views.rb
Overview
Class used for locating templates.
Instance Method Summary collapse
-
#get_layout(controller) ⇒ String|nil
Returns the layout associated with the current request.
-
#get_view(controller) ⇒ String|nil
Returns the view associated with the current request.
-
#initialize(layout_base_dir, view_base_dir) ⇒ TemplateLocator
constructor
A new instance of TemplateLocator.
Constructor Details
#initialize(layout_base_dir, view_base_dir) ⇒ TemplateLocator
Returns a new instance of TemplateLocator.
45 46 47 48 49 50 |
# File 'lib/racket/utils/views.rb', line 45 def initialize(layout_base_dir, view_base_dir) @layout_base_dir = layout_base_dir @view_base_dir = view_base_dir @layout_cache = TemplateCache.new @view_cache = TemplateCache.new end |
Instance Method Details
#get_layout(controller) ⇒ String|nil
Returns the layout associated with the current request. On the first request to any action the result is cached, meaning that the layout only needs to be looked up once.
57 58 59 |
# File 'lib/racket/utils/views.rb', line 57 def get_layout(controller) get_template(TemplateParams.new(:layout, controller, @layout_base_dir, @layout_cache)) end |
#get_view(controller) ⇒ String|nil
Returns the view associated with the current request. On the first request to any action the result is cached, meaning that the view only needs to be looked up once.
66 67 68 |
# File 'lib/racket/utils/views.rb', line 66 def get_view(controller) get_template(TemplateParams.new(:view, controller, @view_base_dir, @view_cache)) end |