(02-07-2017, 04:38 PM)iamthwee Wrote:
(02-07-2017, 04:24 PM)ivantcholakov Wrote: Configuration: https://github.com/ivantcholakov/starter...r_twig.php
But what I meant was let's say the end user, makes their own helper function, and they could create any number of them, it could be really simple or very specific/complex.
How do they call that without having to declare a custom twig function in a config file. (assuming they have no knowledge of adding twig functions)
^^That's my issue.
The set of functions I figured at the moment is enough. I also support widgets, so if a user tries to make something more complex, he/she could use them.
Indefinite need for functions tells me that something wrong is going to happen in the views, IMO. Probably logic that does not belong to a view is implemented there. Everything can be calculated in the controller (or a in a subordinate model) and then just to be passed to the view.
I am not a fan of the almost totally "logic-less" engines like Mustache or Handlebars, but still stays the problem to be solved - what logic belongs to a view and what belongs elsewhere. I think, Twig provides the right balance.
Furthermore, you would have automatic escaping by default, which is important. That is more safe. If your end-user makes security mistakes within the PHP-views, I guess he/she would blame your system, not him/her-self.
Even if you are not a fan of Twig, maybe a significant number of your end-users might be. Try to check this somehow.
IMO, eventually, implementing an optional template engine within your system would check it conceptually. When I migrated my views, I purged my poor decisions about them and as a result my code got better placed than it was before.