Class: ActionView::Base
- Defined in:
- lib/haml/template/patch.rb,
lib/haml/template/plugin.rb,
lib/haml/helpers/action_view_mods.rb
Overview
:nodoc:
Instance Method Summary collapse
- #compile_haml(template, file_name, local_assigns) ⇒ Object
- #compile_template_with_haml(extension, template, file_name, local_assigns) ⇒ Object (also: #compile_template)
- #compile_template_without_haml ⇒ Object
- #delegate_template_exists_with_haml(template_path) ⇒ Object (also: #delegate_template_exists?)
- #output_buffer_with_haml ⇒ Object (also: #output_buffer)
- #render_with_haml(*args, &block) ⇒ Object (also: #render)
- #set_output_buffer_with_haml(new) ⇒ Object (also: #output_buffer=)
Instance Method Details
#compile_haml(template, file_name, local_assigns) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/haml/template/patch.rb', line 26 def compile_haml(template, file_name, local_assigns) render_symbol = assign_method_name(:haml, template, file_name) locals = local_assigns.keys @@template_args[render_symbol] ||= {} locals_keys = @@template_args[render_symbol].keys | locals @@template_args[render_symbol] = Haml::Util.to_hash(locals_keys.map {|k| [k, true]}) = Haml::Template..dup [:filename] = file_name || 'compiled-template' begin Haml::Engine.new(template, ).def_method(CompiledTemplates, render_symbol, *locals_keys) rescue Exception => e if logger logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}" logger.debug "Backtrace: #{e.backtrace.join("\n")}" end base_path = if defined?(extract_base_path_from) # Rails 2.0.x extract_base_path_from(file_name) || view_paths.first else # Rails <=1.2.6 @base_path end raise ActionView::TemplateError.new(base_path, file_name || template, @assigns, template, e) end @@compile_time[render_symbol] = Time.now end |
#compile_template_with_haml(extension, template, file_name, local_assigns) ⇒ Object Also known as: compile_template
19 20 21 22 |
# File 'lib/haml/template/patch.rb', line 19 def compile_template_with_haml(extension, template, file_name, local_assigns) return compile_haml(template, file_name, local_assigns) if extension.to_s == "haml" compile_template_without_haml(extension, template, file_name, local_assigns) end |
#compile_template_without_haml ⇒ Object
23 |
# File 'lib/haml/template/patch.rb', line 23 alias_method :compile_template_without_haml, :compile_template |
#delegate_template_exists_with_haml(template_path) ⇒ Object Also known as: delegate_template_exists?
13 14 15 |
# File 'lib/haml/template/patch.rb', line 13 def delegate_template_exists_with_haml(template_path) template_exists?(template_path, :haml) && [:haml] end |
#output_buffer_with_haml ⇒ Object Also known as: output_buffer
21 22 23 24 |
# File 'lib/haml/helpers/action_view_mods.rb', line 21 def output_buffer_with_haml return haml_buffer.buffer if is_haml? output_buffer_without_haml end |
#render_with_haml(*args, &block) ⇒ Object Also known as: render
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/haml/helpers/action_view_mods.rb', line 4 def render_with_haml(*args, &block) = args.first # If render :layout is used with a block, # it concats rather than returning a string # so we need it to keep thinking it's Haml # until it hits the sub-render if is_haml? && !(.is_a?(Hash) && [:layout] && block_given?) return non_haml { render_without_haml(*args, &block) } end render_without_haml(*args, &block) end |
#set_output_buffer_with_haml(new) ⇒ Object Also known as: output_buffer=
28 29 30 31 32 33 34 |
# File 'lib/haml/helpers/action_view_mods.rb', line 28 def set_output_buffer_with_haml(new) if is_haml? haml_buffer.buffer = new else set_output_buffer_without_haml new end end |