Module: Mjml

Defined in:
lib/mjml.rb,
lib/mjml/parser.rb,
lib/mjml/railtie.rb,
lib/mjml/version.rb,
lib/mjml/mjmltemplate.rb,
lib/generators/mjml/mailer/mailer_generator.rb

Defined Under Namespace

Modules: Generators Classes: Handler, Mjmltemplate, Parser, Railtie

Constant Summary collapse

BIN =
discover_mjml_bin
VERSION =

Version number no longer matches MJML.io version

"2.4.3"
@@template_language =
:erb
@@processing_options =
{}

Class Method Summary collapse

Class Method Details

.check_version(bin) ⇒ Object



12
13
14
15
16
17
# File 'lib/mjml.rb', line 12

def self.check_version(bin)
  version = IO.popen("#{bin} --version").read.chomp
  Gem::Dependency.new('', '~> 3.0').match?('', version)
rescue
  false
end

.discover_mjml_binObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mjml.rb', line 19

def self.discover_mjml_bin
  # Check for a global install of MJML binary
  mjml_bin = 'mjml'
  return mjml_bin if check_version(mjml_bin)

  # Check for a local install of MJML binary
  installer_path = (`npm bin` || `yarn bin`).chomp
  mjml_bin = File.join(installer_path, 'mjml')
  return mjml_bin if check_version(mjml_bin)

  puts "Couldn't find the MJML binary.. have you run $ npm install mjml?"
  nil
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Mjml)

    the object that the method was called on



50
51
52
# File 'lib/mjml.rb', line 50

def self.setup
  yield self if block_given?
end