Tuesday, 15 January 2019

I created my own template engine. Feedback?

After the pretty weak launch of my template engine, there was no interest in it. I can think of reasons why that's the case, but I'd like to hear some feedback. Too much template engines exist already? Or perhaps the syntax looks confusing at first glance?It's called NHP and you can check the GitHub repo here.Personal thoughtsI created the nhpjs.com site with that engine to see if it's actually useful and to check for obvious important features that are missing. I was able to organize things the way I wanted, work quickly, and the syntax was easy to use. It was a nice development experience. It comes with an integration for Express and also a middleware function that gives you PHP-style routing. On paper, it seems that after the release of a well-tested version that is proven to be stable, this engine could be a viable option.Basically, after installing NHP + Express from npm and copying about 20 lines of JS that start a server, you have: - PHP-style routing. - Templates that can use all JavaScript features for logic. - Templates that are modular and can import/export data (besides the markup they generate), which can consist of markup, or even the whole rendered markup of another template. - Access to any Node module - for fetching content (axios, maybe a CMS like Keystone) or formatting content. - Separation of concerns - you can have all templates inside /views and the various modules that deal with a database, for example, in /modules. Then, in any template, you simply require('@/modules/foo') and get access to whatever you need.And of course, you are not forced to use the PHP-style routing middleware, it's just there for flexibility. It's an Express app and you can define whatever routes you need or want.I can't think of a reason why this isn't useful. Perhaps I'm missing something?I'll greatly appreciate any kind of feedback!

Submitted January 15, 2019 at 07:04PM by hdodov

No comments:

Post a Comment