class MJML::Rails::TemplateHandler
Constants
- EXTENSIONS
Supported extensions
Public Class Methods
new(base_handler = :erb)
click to toggle source
# File lib/mjml/rails/template_handler.rb, line 8 def initialize(base_handler = :erb) @base_handler = base_handler end
Public Instance Methods
call(template, source=nil)
click to toggle source
# File lib/mjml/rails/template_handler.rb, line 12 def call(template, source=nil) compiled = get_handler(@base_handler).call(template, source) "::MJML::Parser.new.call!(begin;#{compiled};end).html_safe" end
Private Instance Methods
get_handler(ext)
click to toggle source
# File lib/mjml/rails/template_handler.rb, line 19 def get_handler(ext) handler = instance_variable_get("@#{ext}_handler") if handler.nil? handler = ActionView::Template.registered_template_handler(ext) instance_variable_set("@#{ext}_handler", handler) end handler end