Show HN: Templating engine to make life simpler
github.comA few things I noticed while reading through the readme:
* For me to consider using a PHP library in 2015, it must support Composer.
* Currently, a lot of the API is static. This makes it hard to inject the template engine as a helper into some other code. Personally, I would prefer a non-static API.
* The template and cache paths seem to be fixed to the location of the library. If this becomes a Composer package, they must be configurable.
* From looking at the syntax, how does your library compare to Twig? Sure, the setup process for Twig (initializing the environment, template loader, cache and stuff) is a bit more work, but after that, it's as easy as ``$twig->render('mytemplate.twig', [...data...])``. (Plus, Twig has some nice syntactic sugar, like an else-clause for loops.)
* Is there automatic HTML encoding? This is one of the most compelling reasons for me to use a template engine. Whether or not stuff is automatically encoded, this should be mentioned prominently in the readme so that users don't create insecure templates.
* On a really completely personal note: I don't like ``.tpl`` as a file extension. It's too generic. It's like naming my PHP class files ``.class`` -- IMO the extension should indicate the file syntax/type, not the file's purpose. Plus if I look at your roadmap, using .tpl might be a problem when you support JavaScript as well.
[Edit] I just noticed how negative this all reads. Please take it as constructive cristicism rather than me bashing your work. :)
First off, thank you for the advice, it's really appreciated! Things that are going to be added over the coming days: * Composer support * Less static or hardcoded API * More configurable options * A else clause for foreach loops * HTML encoding which is enforced and must be opted out of per echo for increased security Maybe a different file extension, we'll see
With regards to how it compares to twig, the aim is to take a lot of functionality that twig offers and build on that. I feel like twig hasn't gone far enough with it's attempts to build a templating engine.
Don't worry I took it as constructive criticism from the start, this is why I posted the project here in the first place so thank you!
Hey, just to let you know a lot of the changes you recommended have been implemented so once again thanks for the constructive criticism!