Welcome Guest, Not a member yet? Register   Sign In
Twig help or hindrance
#17

(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

Interesting...

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.  Smile 

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.
Reply


Messages In This Thread
Twig help or hindrance - by ignitedcms - 02-07-2017, 12:36 AM
RE: Twig help or hindrance - by skunkbad - 02-07-2017, 12:57 AM
RE: Twig help or hindrance - by ignitedcms - 02-07-2017, 01:12 AM
RE: Twig help or hindrance - by skunkbad - 02-07-2017, 11:10 AM
RE: Twig help or hindrance - by skunkbad - 02-07-2017, 01:00 AM
RE: Twig help or hindrance - by ignitedcms - 02-07-2017, 01:18 AM
RE: Twig help or hindrance - by ivantcholakov - 02-07-2017, 09:04 AM
RE: Twig help or hindrance - by ignitedcms - 02-07-2017, 10:08 AM
RE: Twig help or hindrance - by ignitedcms - 02-07-2017, 11:52 AM
RE: Twig help or hindrance - by ivantcholakov - 02-07-2017, 01:17 PM
RE: Twig help or hindrance - by ignitedcms - 02-07-2017, 02:53 PM
RE: Twig help or hindrance - by ivantcholakov - 02-07-2017, 03:24 PM
RE: Twig help or hindrance - by ignitedcms - 02-07-2017, 03:38 PM
RE: Twig help or hindrance - by ivantcholakov - 02-07-2017, 05:14 PM
RE: Twig help or hindrance - by Diederik - 02-07-2017, 03:40 PM
RE: Twig help or hindrance - by ignitedcms - 02-07-2017, 03:44 PM
RE: Twig help or hindrance - by Diederik - 02-07-2017, 03:53 PM
RE: Twig help or hindrance - by laynebay - 02-07-2017, 08:17 PM
RE: Twig help or hindrance - by ignitedcms - 02-09-2017, 02:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB