Sha256: c1424998764639a822b3f42d63a7dfa1a42545869e1b6682862817974221b3e5
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
require 'mustache' module Stache module Mustache # # A Convienent Base Class for the views. Subclass this for autoloading magic with your templates. class View < ::Mustache attr_accessor :view, :template, :virtual_path def method_missing(method, *args, &block) view.send(method, *args, &block) end def respond_to?(method, include_private=false) super(method, include_private) || view.respond_to?(method, include_private) end # Redefine where Stache::View templates locate their partials def partial(name) current_dir = Stache.template_base_path.join( self.virtual_path.split("/")[0..-2].join("/") ) lookup_context.view_paths += [current_dir] template_finder = lambda do |partial| if ActionPack::VERSION::MAJOR == 3 && ActionPack::VERSION::MINOR < 2 lookup_context.find(name, [], partial) else # Rails 3.2 and higher lookup_context.find(name, [], partial, [], { formats: [:html], handlers: [:mustache] }) end end template = template_finder.call(true) rescue template_finder.call(false) template.source end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stache-0.9.1 | lib/stache/mustache/view.rb |
stache-0.9.0 | lib/stache/mustache/view.rb |