Picombo comes with builtin support for Mustache view templates
All view files go into the views folder. You need a .rb class along with a .mustache template file. Your view class files should extend the Mustache class:
module Picombo
module Stache
class Home_Index < Mustache
self.template = File.open(Picombo::Core.find_file('views', 'home/index', true, 'mustache').shift).read
end
end
end
You should always set the template in your class. In most scenarios, it’s easiest to read it in from a file as displayed above. You can also specify a raw string template there and not do the file read.
To render the template to your browser, use the output method:
Picombo::Stache::Home_Index.new.output
Autoloader for missing mustache classes.
# File lib/classes/stache.rb, line 26
26: def Stache.const_missing(name)
27: filename = name.to_s
28:
29: require 'views/'+filename.downcase.gsub(/_/, '/')
30:
31: raise name.to_s+' not found!' if ! const_defined?(name)
32:
33: klass = const_get(name)
34: return klass if klass
35: raise klass+" not found!"
36: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.