Class: Inky::Rails::TemplateHandler
- Inherits:
-
Object
- Object
- Inky::Rails::TemplateHandler
- Defined in:
- lib/inky/rails/template_handler.rb
Defined Under Namespace
Modules: Composer
Instance Method Summary collapse
- #call(template, source = nil) ⇒ Object
- #engine_handler ⇒ Object
-
#initialize(compose_with = nil) ⇒ TemplateHandler
constructor
A new instance of TemplateHandler.
Constructor Details
#initialize(compose_with = nil) ⇒ TemplateHandler
Returns a new instance of TemplateHandler.
4 5 6 |
# File 'lib/inky/rails/template_handler.rb', line 4 def initialize(compose_with = nil) @engine_handler = ActionView::Template.registered_template_handler(compose_with) if compose_with end |
Instance Method Details
#call(template, source = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/inky/rails/template_handler.rb', line 16 def call(template, source = nil) compiled_source = if source engine_handler.call(template, source) else engine_handler.call(template) end "Inky::Core.new.release_the_kraken(begin; #{compiled_source};end)" end |
#engine_handler ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/inky/rails/template_handler.rb', line 8 def engine_handler return @engine_handler if @engine_handler type = ::Inky.configuration.template_engine ActionView::Template.registered_template_handler(type) || raise("No template handler found for #{type}") end |