Twig Templating Block (powered by Timber) #3136
jasalt
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
While I couldn't get the team to use Timber in favor of FSE, I've been experimenting with "Twig templating block" which allows writing custom Twig/HTML template in block editor and to map available block bindings to template context variables to supplement standard Timber post data.
It is relatively safe with
unfiltered_htmlrequired, mostly equivalent to Custom HTML block with Twig auto escaping available for some extra safety.Full Site Editor screenshot utilizing it from a site:

Example binding code & template: https://gist.github.com/jasalt/dc3d9b7704da431e184096595e0637ea
Looking to document it better during the autumn but the code is available for experimenting and it's quite succinct (~ 500LOC JS, ~ 400 LOC PHP). There's some juggling with the global state and some edge cases but has been working quite stable for usual stuff.
All reactions