Class: Deas::Erubis::TemplateEngine
- Inherits:
-
TemplateEngine
- Object
- TemplateEngine
- Deas::Erubis::TemplateEngine
- Defined in:
- lib/deas-erubis.rb
Constant Summary collapse
- DEFAULT_HANDLER_LOCAL =
'view'.freeze
- DEFAULT_LOGGER_LOCAL =
'logger'.freeze
Instance Method Summary collapse
-
#compile(template_name, compiled_content) ⇒ Object
this is used when chaining engines where another engine initially loads the template file.
- #erb_handler_local ⇒ Object
- #erb_logger_local ⇒ Object
- #erb_source ⇒ Object
-
#partial(template_name, locals, &content) ⇒ Object
render the template against the given locals.
-
#render(template_name, view_handler, locals, &content) ⇒ Object
render the template including the handler as a local.
Instance Method Details
#compile(template_name, compiled_content) ⇒ Object
this is used when chaining engines where another engine initially loads the template file
45 46 47 |
# File 'lib/deas-erubis.rb', line 45 def compile(template_name, compiled_content) self.erb_source.compile(template_name, compiled_content) end |
#erb_handler_local ⇒ Object
25 26 27 |
# File 'lib/deas-erubis.rb', line 25 def erb_handler_local @erb_handler_local ||= (self.opts['handler_local'] || DEFAULT_HANDLER_LOCAL) end |
#erb_logger_local ⇒ Object
29 30 31 |
# File 'lib/deas-erubis.rb', line 29 def erb_logger_local @erb_logger_local ||= (self.opts['logger_local'] || DEFAULT_LOGGER_LOCAL) end |
#erb_source ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/deas-erubis.rb', line 14 def erb_source @erb_source ||= Source.new(self.source_path, { :ext => self.opts['ext'], :eruby => self.opts['eruby'], :cache => self.opts['cache'], :default_source => self.opts['default_template_source'], :helpers => self.opts['helpers'], :locals => { self.erb_logger_local => self.logger } }) end |
#partial(template_name, locals, &content) ⇒ Object
render the template against the given locals
39 40 41 |
# File 'lib/deas-erubis.rb', line 39 def partial(template_name, locals, &content) self.erb_source.render(template_name, locals, &content) end |
#render(template_name, view_handler, locals, &content) ⇒ Object
render the template including the handler as a local
34 35 36 |
# File 'lib/deas-erubis.rb', line 34 def render(template_name, view_handler, locals, &content) self.erb_source.render(template_name, render_locals(view_handler, locals), &content) end |