- Issue created by @liquidcms
I needed to embed a view into my message template. There is a module which allows views to be embedded as token and that works with Message tpls.
Token format is something like [view:myview:myview-display:arg1:arg2:etc]. But my arg1 in most cases is NID. so maybe this: [view:myview:myview-display:[node:nid]], but sadly Drupal's token system doesnt handle recursive tokens.
So then i thought about twig support. Had numerous other instances when some simple conditional logic wold have been create in a mail template without having to making custom tokens each time this came up. Plus i had recently added tiwg support to the FillPDF module and discovered how easy it is (2 lines of code). So i did up this simple patch to add twig support to message templates. It runs before token processing, so my solution above is simply this:
[view:myview:myview-display:{{ node.id }}] and this works perfectly. But of course much more complex conditional case can now be handled in mail templates as well.
Active
1.0
Code