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
"4.3.2"
- @@template_language =
:erb
- @@raise_render_exception =
true
- @@mjml_binary_version_supported =
"4."
- @@mjml_binary_error_string =
"Couldn't find the MJML #{Mjml.mjml_binary_version_supported} binary.. have you run $ npm install mjml?"
- @@beautify =
true
- @@minify =
false
- @@processing_options =
{}
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.logger ⇒ Object
91
92
93
94
95
|
# File 'lib/mjml.rb', line 91
def logger
@logger ||= Logger.new($stdout).tap do |log|
log.progname = self.name
end
end
|
Class Method Details
.bin_path_from(package_manager) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/mjml.rb', line 44
def self.bin_path_from(package_manager)
_, stdout, _, _ = Open3.popen3("#{package_manager} bin")
stdout.read.chomp
rescue Errno::ENOENT nil
end
|
.check_version(bin) ⇒ Object
19
20
21
22
23
|
# File 'lib/mjml.rb', line 19
def self.check_version(bin)
IO.popen([bin, '--version']) { |io| io.read.include?("mjml-core: #{Mjml.mjml_binary_version_supported}") }
rescue
false
end
|
.discover_mjml_bin ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/mjml.rb', line 25
def self.discover_mjml_bin
mjml_bin = 'mjml'
return mjml_bin if check_version(mjml_bin)
installer_path = bin_path_from('npm') || bin_path_from('yarn')
unless installer_path
puts Mjml.mjml_binary_error_string
return nil
end
mjml_bin = File.join(installer_path, 'mjml')
return mjml_bin if check_version(mjml_bin)
puts Mjml.mjml_binary_error_string
nil
end
|
.setup {|_self| ... } ⇒ Object
84
85
86
|
# File 'lib/mjml.rb', line 84
def self.setup
yield self if block_given?
end
|