1

I am trying to use MJML to create dynamic email content. (official site)

First, this application is running on Windows, so there is no way to run the official compiler on the machine. I may use the official online editor, but it will just drop all syntax that are not recognized, including the PHP tag like <?php. There are similar problem mentioned on the issue page, but they suggest using <mj-raw>, which doesn't work for attributes. (Or I need to code all the component by myself.... then what's the point of using MJML?)

Is there other compiler for MJML in PHP? Like less.php for compiling LESS in PHP?

cytsunny
  • 4,838
  • 15
  • 62
  • 129
  • Not sure about the "Windows" only, seems to me you only need npm: https://github.com/mjmlio/mjml#installation – Veve Feb 03 '17 at 10:28
  • The official page says that when I open the download page on official site. Screenshot: http://i.imgur.com/ZHa7fpD.png – cytsunny Feb 03 '17 at 10:32

2 Answers2

1

You can install the qferr/mjml-php library from the composer and the use the library

Check this article https://medium.com/@qferrer/rendering-mjml-in-php-982d703aa703

Mehyar Sawas
  • 1,187
  • 6
  • 15
0

MJML runs on OSX, Linux and Windows so you can use the official compiler (the bit saying it doesn't run on Windows on the website needs to be updated).

Regarding tags like <?, indeed they are causing issues at the moment because of the parser (they're read as mjml tags which leads the parser to crash).

I don't know of any maintained PHP wrapper for MJML but you might be interested in using the MJML API which makes it language agnostic (it's currently in beta): https://mjml.typeform.com/to/tW2U6K.

Nicolas Garnier
  • 370
  • 1
  • 10
  • um.... I tried to install using npm. It seems the installation is successful, but how should I add it to my system path? `export PATH="$PATH:./node_modules/.bin"` is for linux only.... Sorry I am quite new to npm. – cytsunny Feb 03 '17 at 11:12
  • I think this will enable to add it to your PATH: http://stackoverflow.com/questions/27864040/fixing-npm-path-in-windows-8 – Nicolas Garnier Feb 03 '17 at 11:20
  • @cytsunny you should search for installing npm first, and eventually if you found nothing, ask a distinct question about it. – Veve Feb 03 '17 at 13:39