module Sinatra::FuzzyLayout::TemplatesHelpers
This module is a placeholder for the non-DSL methods. To know more about extending Sinatra
or how the various bindings/encapsulation works, refer to [this material on the topic](www.sinatrarb.com/extensions.html)
This module gets included inside the Sinatra::Base class within the call to `app.helpers TemplatesHelpers`. So we use the class hierarchy to our advantage and override the `render` method to obtain the name of the view and other options based on the name of the view.
Public Instance Methods
render(engine, data, options = {}, locals = {}, &block)
click to toggle source
Calls superclass method
# File lib/sinatra/fuzzy_layout.rb, line 81 def render(engine, data, options = {}, locals = {}, &block) options = get_new_options_and_template(options, data) super end
Private Instance Methods
get_new_options_and_template(options, template)
click to toggle source
Sets the layout option for a particular view template.
Parameters¶ ↑
- options
-
A hash of options generated by the app based on the settings by the user.
- template
-
A
Symbol
representing the name of the view. For example, `:index`
# File lib/sinatra/fuzzy_layout.rb, line 99 def get_new_options_and_template(options, template) old_option = options.fetch(:layout) { false } if settings.enable_list.has_the_template?(template) options.merge!(:layout => (true && old_option)) elsif settings.disable_list.has_the_template?(template) options.merge!(:layout => (false || old_option)) end options end