Class: Haml::Plugin
- Inherits:
-
Object
- Object
- Haml::Plugin
- Defined in:
- lib/haml/plugin.rb
Overview
This module makes Haml work with Rails using the template handler API.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(template)
22 23 24 |
# File 'lib/haml/plugin.rb', line 22
def self.call(template)
new.compile(template)
end
|
Instance Method Details
#cache_fragment(block, name = {}, options = nil)
26 27 28 29 30 |
# File 'lib/haml/plugin.rb', line 26
def cache_fragment(block, name = {}, options = nil)
@view.fragment_for(block, name, options) do
eval("_hamlout.buffer", block.binding)
end
end
|
#compile(template)
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/haml/plugin.rb', line 8
def compile(template)
options = Haml::Template.options.dup
if template.respond_to?(:type)
options[:mime_type] = template.type
elsif template.respond_to? :mime_type
options[:mime_type] = template.mime_type
end
options[:filename] = template.identifier
Haml::Engine.new(template.source, options).compiler.precompiled_with_ambles(
[],
after_preamble: '@output_buffer = output_buffer ||= ActionView::OutputBuffer.new if defined?(ActionView::OutputBuffer)',
)
end
|
#handles_encoding? ⇒ Boolean
6 |
# File 'lib/haml/plugin.rb', line 6
def handles_encoding?; true; end
|