I'm trying to understand if/how you insert Twig variables in blocks in the custom block library.
To clarify, the block's HTML has been configured via the UI at /admin/structure/block/block-content
Standard Twig syntax, e.g. a 'say-something' tag like {{ base_path ~ directory }}
- which I want so I can set an <img src
attibute correctly - doesn't seem to be parsed at all and I don't see a way to use Tokens.
Examining the HTML source with Twig debugging on, it's theme hook is listed as "field", so if I add a preprocess function:
function themename_preprocess_field(array &$variables, $hook) {
xdebug_break():
}
- that's being called rather too often
- when it does reach the custom block, there doesn't seem to be anything in $variables that labels it as such, other than a render array with the processed text:
$variables['items'][0]['content]['#text']
What's the simplest approach for this? Is the only way to do it to write a module?
Thanks, William