Class ActionView::Base
In: lib/haml/template/patch.rb
lib/haml/template/plugin.rb
lib/haml/helpers/action_view_mods.rb
Parent: Object

Methods

External Aliases

delegate_template_exists? -> delegate_template_exists_without_haml
compile_template -> compile_template_without_haml
render -> render_without_haml

Public Instance methods

[Source]

    # File lib/haml/template/patch.rb, line 26
26:     def compile_haml(template, file_name, local_assigns)
27:       render_symbol = assign_method_name(:haml, template, file_name)
28:       locals = local_assigns.keys
29: 
30:       @@template_args[render_symbol] ||= {}
31:       locals_keys = @@template_args[render_symbol].keys | locals
32:       @@template_args[render_symbol] = Haml::Util.to_hash(locals_keys.map {|k| [k, true]})
33: 
34:       options = Haml::Template.options.dup
35:       options[:filename] = file_name || 'compiled-template'
36: 
37:       begin
38:         Haml::Engine.new(template, options).def_method(CompiledTemplates, render_symbol, *locals_keys)
39:       rescue Exception => e
40:         if logger
41:           logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
42:           logger.debug "Backtrace: #{e.backtrace.join("\n")}"
43:         end
44: 
45:         base_path = if defined?(extract_base_path_from)
46:                       # Rails 2.0.x
47:                       extract_base_path_from(file_name) || view_paths.first
48:                     else
49:                       # Rails <=1.2.6
50:                       @base_path
51:                     end
52:         raise ActionView::TemplateError.new(base_path, file_name || template, @assigns, template, e)
53:       end
54: 
55:       @@compile_time[render_symbol] = Time.now
56:     end
compile_template(extension, template, file_name, local_assigns)

[Source]

    # File lib/haml/template/plugin.rb, line 50
50:     def compile_template(handler, template, file_name, local_assigns)
51:       render_symbol = assign_method_name(handler, template, file_name)
52: 
53:       # Move begin up two lines so it captures compilation exceptions.
54:       begin
55:         render_source = create_template_source(handler, template, render_symbol, local_assigns.keys)
56:         line_offset = @@template_args[render_symbol].size + handler.line_offset
57:       
58:         file_name = 'compiled-template' if file_name.blank?
59:         CompiledTemplates.module_eval(render_source, file_name, -line_offset)
60:       rescue Exception => e # errors from template code
61:         if logger
62:           logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
63:           logger.debug "Function body: #{render_source}"
64:           logger.debug "Backtrace: #{e.backtrace.join("\n")}"
65:         end
66: 
67:         # There's no way to tell Haml about the filename,
68:         # so we've got to insert it ourselves.
69:         e.backtrace[0].gsub!('(haml)', file_name) if e.is_a?(Haml::Error)
70:         
71:         raise ActionView::TemplateError.new(extract_base_path_from(file_name) || view_paths.first, file_name || template, @assigns, template, e)
72:       end
73:       
74:       @@compile_time[render_symbol] = Time.now
75:       # logger.debug "Compiled template #{file_name || template}\n ==> #{render_symbol}" if logger
76:     end

[Source]

    # File lib/haml/template/patch.rb, line 19
19:     def compile_template_with_haml(extension, template, file_name, local_assigns)
20:       return compile_haml(template, file_name, local_assigns) if extension.to_s == "haml"
21:       compile_template_without_haml(extension, template, file_name, local_assigns)
22:     end
delegate_template_exists?(template_path)

[Source]

    # File lib/haml/template/patch.rb, line 13
13:     def delegate_template_exists_with_haml(template_path)
14:       template_exists?(template_path, :haml) && [:haml]
15:     end

[Source]

    # File lib/haml/helpers/action_view_mods.rb, line 20
20:       def output_buffer_with_haml
21:         return haml_buffer.buffer if is_haml?
22:         output_buffer_without_haml
23:       end
render(*args, &block)

Alias for render_with_haml

[Source]

    # File lib/haml/helpers/action_view_mods.rb, line 3
 3:     def render_with_haml(*args, &block)
 4:       options = args.first
 5: 
 6:       # If render :layout is used with a block,
 7:       # it concats rather than returning a string
 8:       # so we need it to keep thinking it's Haml
 9:       # until it hits the sub-render
10:       if is_haml? && !(options.is_a?(Hash) && options[:layout] && block_given?)
11:         return non_haml { render_without_haml(*args, &block) }
12:       end
13:       render_without_haml(*args, &block)
14:     end

[Source]

    # File lib/haml/helpers/action_view_mods.rb, line 27
27:       def set_output_buffer_with_haml(new)
28:         if is_haml?
29:           new = String.new(new) if Haml::Util.rails_xss_safe? &&
30:             new.is_a?(Haml::Util.rails_safe_buffer_class)
31:           haml_buffer.buffer = new
32:         else
33:           set_output_buffer_without_haml new
34:         end
35:       end

[Validate]