mjml icon indicating copy to clipboard operation
mjml copied to clipboard

how to export the HTML

Open Chronis77 opened this issue 7 years ago • 6 comments

Hi Artf,

I seem to be bothering you on all fronts. Sorry.

I want to be able to get the converted mjml (HTML). What command should I use to get this?

If i open the "view code" dialog if gives the error: "Line 22 (mj-body) — Element mj-body doesn't exist or is not registered" . The mjml side all looks fine but nothing renders on the HTML side.

It also throws a js error: grapes.min.js:2 Uncaught TypeError: Cannot read property 'split' of undefined at Xs (grapes.min.js:2) at Pa.splitLines (grapes.min.js:2) at Pa.<anonymous> (grapes.min.js:2) at Pa.setValue (grapes.min.js:2) at Ho.setValue (grapes.min.js:2) at n.setContent (grapes.min.js:2) at n.run (grapesjs-mjml.min.js:108) at n.updateActive (grapes.min.js:2) at y (grapes.min.js:2) at v (grapes.min.js:2)

Chronis77 avatar Jul 05 '17 14:07 Chronis77

editor.runCommand('mjml-get-code') should output the html code

artf avatar Jul 05 '17 15:07 artf

@artf When are you going to update this repo with more stable version ?

Thanks for your initiative, Amazing Work 👍

jsahani avatar Jul 05 '17 21:07 jsahani

I still get the error:

"Line 22 (mjml) — Element mjml doesn't exist or is not registered" and "Line 22 (mj-body) — Element mj-body doesn't exist or is not registered".

I don't output the content between the gjs tags. I rely on pulling data from the Store manager. I think this causes the issue:

   storageManager: {
                  type: 'remote',
                  stepsBeforeSave: 5,
                  autoload: true,
                  autosave: true,
                  urlStore: '<?php echo Yii::app()->baseUrl . '/index.php/campaigns/'.$campaign->campaign_uid.'/push_campaign_template'; ?>',
                  urlLoad: '<?php echo Yii::app()->baseUrl . '/index.php/campaigns/'.$campaign->campaign_uid.'/pull_campaign_template'; ?>',
                  contentTypeJson: true,
                  params: {},   
          },

Chronis77 avatar Jul 06 '17 07:07 Chronis77

Figured it out.

const mjml = opt.preMjml + editor.getHtml() + opt.postMjml; Appends before the opening code and to the end. If you already have these tags in the code it causes an error.

Chronis77 avatar Jul 06 '17 10:07 Chronis77

@Chronis77 good to know, but I didn't get if the error is caused by your config with preMjml/postMjml or something else

artf avatar Jul 06 '17 12:07 artf

If you include the tags:

into your code it does not work. Your code appends those tags already, so you end up getting something like:

which the converter then fails on.

Chronis77 avatar Jul 07 '17 07:07 Chronis77

Any code did not work for me. I found it from source code

editor.runCommand('mjml-code-to-html')?.html

teatalay avatar Mar 02 '23 15:03 teatalay