Module: Mjml
- Defined in:
- lib/mjml.rb,
lib/mjml/scope.rb,
lib/mjml/config.rb,
lib/mjml/mailer.rb,
lib/mjml/render.rb,
lib/mjml/version.rb
Defined Under Namespace
Modules: Config, Mailer
Classes: Render, Scope
Constant Summary
collapse
- VERSION =
"0.0.8"
Class Method Summary
collapse
Class Method Details
27
28
29
|
# File 'lib/mjml.rb', line 27
def self.configure
yield Config
end
|
.render(path, args = {}, instance = nil, &block) ⇒ Object
12
13
14
15
|
# File 'lib/mjml.rb', line 12
def self.render(path, args = {}, instance = nil, &block)
scope = Scope.new(instance, args)
Render.new(path, scope, block).execute
end
|
.template(template_mjml) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/mjml.rb', line 17
def self.template(template_mjml)
retries ||= 0
mjml_path = "#{Dir.pwd}/tmp/template-#{SecureRandom.uuid}.mjml"
File.write(mjml_path, template_mjml)
render(mjml_path)
rescue Errno::ENOENT
Dir.mkdir "#{Dir.pwd}/tmp"
retry if (retries += 1) < 3
end
|