Sha256: 0a1dd9a7a92392b6d2a1ba6f6a11c5a6d5051a7463bc0607056fbc2a630cf533
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
module Stache # # A Convienent Base Class for the views. Subclass this for autoloading magic with your templates. # # e.g. if the handler is loading a template from templates/ class View < Mustache attr_accessor :view, :template 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: # # (1) in the same directory as the current template file. # (2) in the shared templates path (can be configured via Config.shared_path=(value)) # def partial(name) partial_name = "_#{name}.#{Stache.template_extension}" template_dir = Pathname.new(self.class.template_file).dirname partial_path = File.expand_path(File.join(Stache.template_base_path, template_dir, partial_name)) unless File.file?(partial_path) partial_path = "#{Stache.shared_path}/#{partial_name}" end # ::Rails.logger.info "LOADING PARTIAL: #{partial_path}" File.read(partial_path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stache-0.0.2 | lib/stache/view.rb |
stache-0.0.1 | lib/stache/view.rb |