Class: MJML::Rails::TemplateHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/mjml/rails/template_handler.rb

Overview

MJML Template handler for Rails

Constant Summary collapse

EXTENSIONS =

Supported extensions

Hash[erb: :mjml, slim: :mjmlslim, haml: :mjmlhaml]

Instance Method Summary collapse

Constructor Details

#initialize(base_handler = :erb) ⇒ TemplateHandler

Returns a new instance of TemplateHandler.



8
9
10
# File 'lib/mjml/rails/template_handler.rb', line 8

def initialize(base_handler = :erb)
  @base_handler = base_handler
end

Instance Method Details

#call(template, source = nil) ⇒ Object



12
13
14
15
# 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