Twig support for field processing.

Created on 10 May 2023, about 1 year ago
Updated 14 May 2023, about 1 year ago

Problem/Motivation

A use case which seems to come up for us every day:

if this token A has this value then print token Y else print "some string".

This would likely be solved by some basic conditional support. In an ideal world, twig support could be added. This obviously give far more power than simple conditionals. Not sure entirely what would be involved in that. Twig is based off variables which have been preprocessed to be available for the template. I guess for this, some preprocess function would be needed to allow twig to know about all the the std tokens available in the token browser.

EDIT
----------
After looking at this and seeing how simple it is to add twig support; i changed the title of this request.

A bit odd but although i have this working (and it is awesome) I havent created a patch. Mostly as it is no use for our project as the numerous patches i have supplied over the past have never made it in quite as expected resulting in us having a custom patch to add all the features we require (most of which have since been committed to 5.0.x). I have suggested to my client we should resolve this situation to get us back in sync with the main development flow here (5.1.x).

So for now i am just gauging the interest in this feature. Basically I have added twig processing to both the Fill in and Transform definitions of a field. I have also included an enable option for both of these (not sure needed but i guess if someone needed "{{}}" in their field). Also, wasnt sure this was needed for the Transform as likely the entire idea of transform is no longer needed with this ability for Fill In (as it can do any sort of Transform available to Twig which is significantly more than what Transform provides), but easy to add to threw it in there as well.

My guess is this feature likely fixes multiple requests already posted here.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

5.1

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada liquidcms

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024