Module: Zafu::ControllerMethods
- Defined in:
- lib/zafu/controller_methods.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#get_template_text(path, base_path) ⇒ Object
This method should return the template for a given ‘src’ and ‘base_path’.
- #template_url_for_asset(opts) ⇒ Object
- #zafu_context ⇒ Object
- #zafu_node(name, klass) ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/zafu/controller_methods.rb', line 3 def self.included(base) base.helper_method :zafu_context, :get_template_text, :template_url_for_asset if RAILS_ENV == 'development' base.class_eval do def render_for_file_with_rebuild(template_path, status = nil, layout = nil, locals = {}) #:nodoc: path = template_path.respond_to?(:path_without_format_and_extension) ? template_path.path_without_format_and_extension : template_path logger.info("Rendering #{path}" + (status ? " (#{status})" : '')) if logger # if params[:rebuild] == 'true' t = self.view_paths.find_template(template_path, 'html') t.previously_last_modified = nil # end render_for_text @template.render(:file => template_path, :locals => locals, :layout => layout), status rescue => err puts err.backtrace.join("\n") end alias_method_chain :render_for_file, :rebuild end end end |
Instance Method Details
#get_template_text(path, base_path) ⇒ Object
This method should return the template for a given ‘src’ and ‘base_path’.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/zafu/controller_methods.rb', line 33 def get_template_text(path, base_path) [path, "#{base_path}/#{path}"].each do |p| begin t = self.view_paths.find_template(p, 'html') # FIXME: format ? rescue ActionView::MissingTemplate t = nil end return [t.source, t.path, t.base_path] if t end nil end |
#template_url_for_asset(opts) ⇒ Object
45 46 47 |
# File 'lib/zafu/controller_methods.rb', line 45 def template_url_for_asset(opts) opts[:src] end |
#zafu_context ⇒ Object
27 28 29 |
# File 'lib/zafu/controller_methods.rb', line 27 def zafu_context @zafu_context ||= {} end |
#zafu_node(name, klass) ⇒ Object
23 24 25 |
# File 'lib/zafu/controller_methods.rb', line 23 def zafu_node(name, klass) zafu_context[:node] = Zafu::NodeContext.new(name, klass) end |