Twig help or hindrance |
02-07-2017, 05:14 PM
(This post was last modified: 02-07-2017, 05:15 PM by ivantcholakov. Edit Reason: a typo ) (02-07-2017, 03:38 PM)iamthwee Wrote:(02-07-2017, 03:24 PM)ivantcholakov Wrote: Configuration: https://github.com/ivantcholakov/starter...r_twig.php 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. |
Welcome Guest, Not a member yet? Register Sign In |