Class: Mjml::MrmlParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ MrmlParser

Create new parser

Parameters:

  • input (String)

    The string to transform in html



10
11
12
# File 'lib/mjml/mrml_parser.rb', line 10

def initialize(input)
  @input = input
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



5
6
7
# File 'lib/mjml/mrml_parser.rb', line 5

def input
  @input
end

Instance Method Details

#renderString

Render mjml template

Returns:

  • (String)


17
18
19
20
21
22
23
24
25
26
# File 'lib/mjml/mrml_parser.rb', line 17

def render
  MRML.to_html(input)
rescue NameError
  Mjml.logger.fatal('MRML is not installed. Please add `gem "mrml"` to your Gemfile.')
  raise
rescue StandardError
  raise if Mjml.raise_render_exception

  ''
end