arnaud-lb / MtHaml

Multi target HAML (HAML for PHP, Twig, <your language here>)
Other
359 stars 54 forks source link

Command to convert to phtml #101

Open jeffbdavenport opened 7 years ago

jeffbdavenport commented 7 years ago

This program looks quite awesome, however it's unrealistic to include the entire MtHaml API into a custom PHP module for an existing platform, it would be awesome if I could convert my MtHaml files into phtml files. Like the coffeescript command coffee -c $file would do.

Boorj commented 7 years ago

Do you want to use mthaml inside nodejs stack (coffee ... command uses node.js) ? What is the purpose? MThaml compiler is made on PHP (as twig is), so you will need php.exe anyway. Perhaps, until you rewrite all lexers, parsers and other parts on javascript to be used inside nodejs stack. Correct me, if I'm wrong. There are several implementations of twig compiler for js, but twig is much more popular than mthaml is. So if it helps - you can convert mthaml-> twig by php, and twig->html by javascript (node).

You still can compile *.haml files with php your_script_that_generates_html.php > result.html

jeffbdavenport commented 7 years ago

For instance in Magento 2 the template files are written in plain php / html code in a .phtml file. But I don't want to just include the entire MtHtml code into the Magento 2 module because that is just unnecessary overhead. I was hoping to have something that I could write and manage the php / html code in a slim format, and the export the files into .phtml files. I can't just convert it to plain html and put that into the module that would break the module and make it unusable.

Boorj commented 7 years ago

i think mthaml could be converted to php+html, why doesn't it fit your goals?

jeffbdavenport commented 7 years ago

Does it actually output the php+html? Or is it just saying that it interprets it that way? In other words can I write a short script with mthtml to save the php+html output to another file?

Boorj commented 7 years ago

Even if you try to look into php cache of your framework (symfony, for example), you'll see that mthaml files are rendered to php. So yes, if you go to this section, you'll see that the 1st example shows you how to render haml to php file.