Class: Mjml::Parser
- Inherits:
-
Object
- Object
- Mjml::Parser
- Defined in:
- lib/mjml/parser.rb
Instance Method Summary collapse
-
#initialize(input) ⇒ Parser
constructor
Create new parser.
-
#render ⇒ String
Render mjml template.
-
#run ⇒ String
Exec mjml command.
Constructor Details
#initialize(input) ⇒ Parser
Create new parser
7 8 9 10 11 |
# File 'lib/mjml/parser.rb', line 7 def initialize input file = File.open(in_tmp_file, 'w') file.write(input) file.close end |
Instance Method Details
#render ⇒ String
Render mjml template
16 17 18 19 20 21 22 23 |
# File 'lib/mjml/parser.rb', line 16 def render result = run remove_tmp_files result rescue "" end |
#run ⇒ String
Exec mjml command
28 29 30 31 32 33 34 35 36 |
# File 'lib/mjml/parser.rb', line 28 def run command = "#{mjml_bin} -r #{in_tmp_file} -o #{out_tmp_file}" # puts command `#{command}` file = File.open(out_tmp_file, 'r') str = file.read file.close str end |