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.6"

Class Method Summary collapse

Class Method Details

.configure {|Config| ... } ⇒ Object

Yields:



23
24
25
# File 'lib/mjml.rb', line 23

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
# File 'lib/mjml.rb', line 17

def self.template(template_mjml)
  mjml_path = "#{Dir.pwd}/tmp/template-#{SecureRandom.uuid}.mjml"
  File.write(mjml_path, template_mjml)
  render(mjml_path)
end