Open nikmartin opened 9 years ago
Also, atom-beautify is version 0.27.0
Install language-ejs first and then try changing the grammar in Atom to JavaScript Template
(EJS). You were on the right track. Let me know if that works.
Looks good! I was not aware that I needed to install a language support package.
If that works for beautifying .TPL
then I would like to add explicit support for it, instead of this work around.
What language package do you use for TPL extension and could you provide a nice sample input file so I could add to the tests. Thanks!
OK sure. I use lodash and/or underscore templates, and they are functionally equivalent to EJS. The tpl extension is of my own making, since I wanted to distinguish them from server-side ejs templates which I also use. A .tpl is typically NOT a complete html file and does not embed a template using <script></script>
tags.
Here is a self contained template that works using underscore.js AND lodash.js:
https://gist.github.com/nikmartin/d19c65ae5a07c19bbfef
Since this is a proper HTML file <script type="text/template" class="template"> ...</script>
is properly beautified if the file Grammar is HTML.
A test case of using a pure inline template with require.js is: https://gist.github.com/nikmartin/c04980c85ac0d6b6c11b It currently gets beautified properly when the Grammar is set to 'JavaScript Template' This is a standalone inline .tpl that would be typical using client side .tpl files that are included at runtime using require.js I intentionally uglified it to see if it gets beautified peoperly, and it does.
Actually, this is a test that fails. the href gets stripped from links:
`
`
/cc @prettydiff any ideas on the failing test above?
Let me know when this is working on Pretty Diff and it can be expedited on Atom Beautify. Thanks!
I use client side underscore templates using requirejs and the text plugin, with a .tpl extension My templates look like normal ejs/underscore style templates:
The file is detected as 'HTML' byt atom, and on saving it gets beautified into:
note the space:
<%=d ata
This pretty much hoses my files. Is there a way to NOT beautify anything inside "<% * "%>", or to map .tpl to ejs? in the status bar, the fiel type is listed as 'HTML' and if i try to change that, ejs is not a choice