connectivedx / Phoenix

http://connectivedx.github.io/Phoenix/
33 stars 5 forks source link

Replace PHP Templates #188

Open drolsen opened 8 years ago

drolsen commented 8 years ago

@elseloop Lets use this ticket to keep an on going conversation about PHP template shift.

I know we are working on a Handlebars version to replace our PHP templates, but I thought it might be worth while to show how Jade template engine would work (branch: http://tinyurl.com/zlvqzjg). Jade is widely used and actually comes with Node Express for application framework.

I built us a helpful form field mixin too: http://tinyurl.com/huaz8dl

Ultimately this leaves us working with cleaner template source: http://tinyurl.com/hwon6vg Also, much maths can be done: http://tinyurl.com/ja3p2py

Code references = http://jade-lang.com/reference/ Jade gulp file configuration = http://jade-lang.com/api/ Gulp Module = https://www.npmjs.com/package/gulp-jade

And discuss...

ajmueller commented 8 years ago

I've been using Jade on a lot of projects lately and LOVE it. Plus it's being renamed to Pug and who doesn't love pugs?!

I think the only concern might be how back-end devs would be able to digest the compiled HTML templates. Having PHP templates broken out into easily digestible pieces that line up well with Sitecore or other CMS components makes it easy for them to copy/paste into their environment. Using Jade, they'd have to have a way to know how they need to be broken up (which may very well be handled perfectly by using HTML comments similar to how @kamsar uses HTML comments to separate Sitecore components).

drolsen commented 8 years ago

@ajmuller Good point. I did add a /inc/components/ folder for us to house our include components (I think something we are trying to do more often now), however I too wonder if these would be easily digestible for backed implementations.

ajmueller commented 8 years ago

@devinrayolsen ah, very nice. Since the compiled HTML results in those components being incorporated into other HTML, though, the best way (I would imagine) to help back-end devs would be to add './templates/inc/**/*.jade' to the paths property of the HTML rendering config option. That way you get the components compiled into the larger templates, but they also get compiled on their own. This, along with comments in the Jade templates to help with context, would allow back-end devs to consume the markup without having to learn Jade's syntax (plus they can copy/paste as before).

drolsen commented 8 years ago

@ajmuller Great point, thanks! Updated.