Class: MJML::Parser

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

Overview

Parser for MJML templates

Defined Under Namespace

Classes: ExecutableNotFound, InvalidTemplate

Constant Summary collapse

ROOT_TAGS_REGEX =
%r{<mjml.*>.*<\/mjml>}im

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.

Raises:



11
12
13
# File 'lib/mjml/parser.rb', line 11

def initialize
  raise ExecutableNotFound if MJML.executable_version.nil?
end

Instance Method Details

#call(template) ⇒ Object



15
16
17
18
19
# File 'lib/mjml/parser.rb', line 15

def call(template)
  call!(template)
rescue InvalidTemplate
  nil
end

#call!(template) ⇒ Object



21
22
23
24
# File 'lib/mjml/parser.rb', line 21

def call!(template)
  @template = template
  exec!
end