Object
The template controller enables your application to take advantage of view templating and auto rendering.
To use it, simply tell your controllers to extend Picombo::Controllers::Template. You must also explicitly call the parent initialize method in your controllers:
def initialize
super
end
The default template view is called ‘layout’ which is located in views/layout.rb. You can change this on a per controller basis by changing the @template vartiable in the controller’s constructor:
@template = 'foobar_template'
Now, you can use @template in your controller and it will always use the same template. The template will automatically render at the end of the controller execution, so there is no need to call @template.output manually
# File lib/controllers/template.rb, line 20
20: def initialize
21: @template = 'layout' if @template.nil?
22: @auto_render = true
23:
24: @template = Picombo::Stache::const_get(@template.capitalize).new if @template.is_a?(String)
25:
26: Picombo::Event.add('system.display') do |data|
27: if @auto_render
28: if Picombo::Core.cli
29: return @template.render
30: end
31:
32: @template.output
33: end
34: end
35: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.