- Status changed to Active
4 months ago 4:41pm 9 August 2024 - π©πͺGermany Anybody Porta Westfalica
Here's a valid use-case: β¨ Provide a token "Link" type Needs work
Twig would be super handy for cases where you need more complex markup, for example a button. If you finally need to be able to translate parts of the labels, then the textarea solution isn't flexible enough anymore. So I totally agree with the others here, a Twig type would be super powerful! π¦Ύπ¦Έ
- First commit to issue fork.
- π©πͺGermany Anybody Porta Westfalica
@Grevil: Rendering can simply be done using https://www.drupal.org/node/2311123 β
What I'm not yet sure about is, which variables we should add to the twig
#context
(is the entity available here, where the field is added on?) and if we should run the result through token replacement (maybe as option?) We should then add a note that token replacement happens after twig rendering.In result this means that tokens can't replace twig variables functionally. Best would be to have both so.
- Status changed to Needs review
4 months ago 2:35pm 12 August 2024 - π©πͺGermany Grevil
All done, please review! I'll do some manual testing, while this can get reviewed already! π
- Merge request !21Issue #3064638: Provide a Twig extrafield type (with token support) β (Open) created by Grevil
- Status changed to Needs work
4 months ago 2:47pm 12 August 2024 - π©πͺGermany Anybody Porta Westfalica
GREAT work @Grevil! I left some comments :)
@droath would you be fine with that, once it's finished? What do the others here think?
- πΊπΈUnited States droath
@Grevil! Much appreciated, I've been waiting to implement this feature for a while! :)
@Anybody Yes, once those issues are resolved and marked as reviewed by the community, I'll merge this into the dev release.
- Merge request !23Issue #3064638: Provide a Twig extrafield type (without token support) β (Open) created by Grevil
- Status changed to Needs review
4 months ago 7:45am 13 August 2024 - π©πͺGermany Grevil
@Anybody and I discussed the token support internally, and we agree, that the twig context variables are the better approach, making the token support obsolete.
We inject a few global variables and the entity itself as context from the get-go and if the user needs even more context variables, he can easily implement "hook_entity_extra_field_twig_context_alter" to provide even further context variables!
Furthermore, the UX doesn't suffer from having no states available for the token tree.
In the end, @droath should decide! :)
Note, that if we want to merge the old implementation WITH token support some few more additions need to be made to that branch (e.g. schema).
- Status changed to Needs work
4 months ago 8:17am 13 August 2024 - π©πͺGermany Anybody Porta Westfalica
Great work @Grevil, just left some final comments. I agree we should leave out tokens here for now and use Twig context, which is even more powerful. If tokens will ever be needed, someone can take the alternative MR and revive it as follow-up. We shouldn't do this for unsure benefit.
- Status changed to Needs review
4 months ago 8:50am 13 August 2024 - π©πͺGermany Grevil
grevil β changed the visibility of the branch 3064638-provide-a-twig to hidden.
- Status changed to RTBC
4 months ago 8:54am 13 August 2024 - π©πͺGermany Anybody Porta Westfalica
GREAT! RTBC!
@droath would you mind having a look and merge this? Maybe tag a new release afterwards? Would be great to have this GA!
- π©πͺGermany Anybody Porta Westfalica
@droath any chance to merge this and tag a new release? :)