Class: Mustache::Rails
- Defined in:
- lib/generators/mustache/install/templates/lib/mustache_rails.rb
Overview
Remember to use {{yield}} (3 mustaches) to skip escaping HTML Using {{tag}} will skip escaping HTML so if your mustache methods return HTML, be sure to interpolate them using 3 mustaches.
Defined Under Namespace
Modules: Config Classes: TemplateHandler
Instance Attribute Summary collapse
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
- #method_missing(method, *args, &block) ⇒ Object
-
#partial(name) ⇒ Object
Redefine where Mustache::Rails templates locate their partials:.
- #respond_to?(method, include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
12 13 14 |
# File 'lib/generators/mustache/install/templates/lib/mustache_rails.rb', line 12 def method_missing(method, *args, &block) view.send(method, *args, &block) end |
Instance Attribute Details
#view ⇒ Object
Returns the value of attribute view.
10 11 12 |
# File 'lib/generators/mustache/install/templates/lib/mustache_rails.rb', line 10 def view @view end |
Instance Method Details
#partial(name) ⇒ Object
Redefine where Mustache::Rails 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))
25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/mustache/install/templates/lib/mustache_rails.rb', line 25 def partial(name) partial_name = "_#{name}.#{Config.template_extension}" template_dir = Pathname.new(self.class.template_file).dirname partial_path = File.("#{template_dir}/#{partial_name}") unless File.file?(partial_path) partial_path = "#{Config.shared_path}/#{partial_name}" end File.read(partial_path) end |
#respond_to?(method, include_private = false) ⇒ Boolean
16 17 18 |
# File 'lib/generators/mustache/install/templates/lib/mustache_rails.rb', line 16 def respond_to?(method, include_private=false) super(method, include_private) || view.respond_to?(method, include_private) end |