Class: Malline::RailsHandler
- Inherits:
-
ActionView::TemplateHandler
- Object
- ActionView::TemplateHandler
- Malline::RailsHandler
- Includes:
- ActionView::TemplateHandlers::Compilable
- Defined in:
- lib/malline/adapters/rails-2.1.rb
Overview
Malline template handler for Rails 2.1
We use Compilable-interface, even though Malline templates really doesn’t compile into anything, but at least template files won’t always be re-read from files. Builder templates (.builder|.rxml) also use this interface.
Class Method Summary collapse
-
.line_offset ⇒ Object
We have three lines framework code before real template code in ‘compiled code’.
Instance Method Summary collapse
-
#cache_fragment(block, name = {}, options = nil) ⇒ Object
Get the rendered fragment contents.
-
#compile(template) ⇒ Object
Compiles the template, i.e.
Class Method Details
.line_offset ⇒ Object
We have three lines framework code before real template code in ‘compiled code’
29 30 31 |
# File 'lib/malline/adapters/rails-2.1.rb', line 29 def self.line_offset 3 end |
Instance Method Details
#cache_fragment(block, name = {}, options = nil) ⇒ Object
Get the rendered fragment contents
45 46 47 48 49 |
# File 'lib/malline/adapters/rails-2.1.rb', line 45 def cache_fragment block, name = {}, = nil @view.fragment_for(block, name, ) do eval("__malline_handler.rendered", block.binding) end end |
#compile(template) ⇒ Object
Compiles the template, i.e. return a runnable ruby code that initializes a new Malline::Base objects and renders the template.
35 36 37 38 39 40 41 42 |
# File 'lib/malline/adapters/rails-2.1.rb', line 35 def compile template path = template.path.gsub('\\', '\\\\\\').gsub("'", "\\\\'") "__malline_handler = Malline::Base.new self malline.path = '#{path}' __malline_handler.render do #{template.source} end" end |