Class: Mjml::Remote::Template
- Inherits:
-
Object
- Object
- Mjml::Remote::Template
- Defined in:
- lib/mjml/remote/template.rb
Defined Under Namespace
Classes: ParseError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input) ⇒ Template
constructor
A new instance of Template.
- #render ⇒ Object
Constructor Details
#initialize(input) ⇒ Template
13 14 15 |
# File 'lib/mjml/remote/template.rb', line 13 def initialize(input) @input = input end |
Class Method Details
.to_html(compiled_source) ⇒ Object
10 11 12 |
# File 'lib/mjml/remote/template.rb', line 10 def self.to_html(compiled_source) new(compiled_source).render.html_safe end |
Instance Method Details
#render ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mjml/remote/template.rb', line 16 def render response = Faraday.post( Mjml::Remote.endpoint, @input, Mjml::Remote.headers ) content = JSON.parse(response.body) if response.success? content["html".freeze] else raise ParseError.new(content) end end |