Closed vanillamasonry closed 4 years ago
Hi,
Could you elaborate what you mean by that?
You could theoretically treat it like php, but the main idea is that data is fetched first and given to the engine to populate fields. The logic in the template would behave as you would see in something like php... There is nothing stopping functions being added that would fetch data.
Also, <% %> could be changed to <? ?> if required.
But the intent was not to replicate php... I think there are projects that allow for php to be embedded.
Regards, Conrad
Hi,
Ex: https://mustache.github.io/ is available in many languages. You can use the same template with PHP, Javascrpit ... including Delphi https://github.com/synopse/dmustache, unfortunately the Delphi version is not updated. Having a strong cross language template engine will be very useful.
Thanks, Paul
Hi Paul,
The objective initially was not to create another 'standard' template format, but to have a relatively feature rich template engine in Delphi...
I think something like Mustache is easier to translate to multiple languages as it is fairly logicless, except in order to use it you have to know syntax fairly well in order to understand how the template behaves. I rather wanted to have logic statements appear more explicitly in the script so that it was easily readable and understandable by anyone non technical without having to read a template specification document (which something like mustache does actually require). e.g. {< }, {{ }} , {{# }}...
Other languages have template engines that may have inspired me: e.g. in Golang: https://golang.org/pkg/text/template/ in Java: https://velocity.apache.org/engine/1.7/user-guide.html#what-can-velocity-do-for-me or https://www.thymeleaf.org/ In Python: https://palletsprojects.com/p/jinja/ (many others on https://wiki.python.org/moin/Templating#Templating_Engines)
The project started mainly from me in delphi by not finding something that suited my requirements...
Anyways, getting back to the original question ... translating this to other languages is not on the agenda without a real sponsor... The template language employed is fairly easy to understand. I think creating a cross platform template engine for multiple languages would really need a very special use case and very doable. In my scenario, I wanted something for Delphi where I didn't find something suiting my requirements.
Sorry, that was a bit long winded - but hopefully addressed your question. I'm happy for any suggestions for improvements, bug reports and other feedback.
Regards, Conrad
Oh, forgot to say. This doesn't work with Free Pascal yet... so when I get to that, I may either make it compatible or a special version.
There will be a PHP version?
Thanks, Paul