Twig Templating Block Codeberg
Twig templating in WordPress Editor (Gutenberg) with quite extensive Block Bindings and Template Parts & Block Patterns support, powered by Timber. Works pretty much but things are stabilizing. Docs coming soon.
by Jarkko Saltiola · codeberg.org/jasalt/twig-templating-block
★ 0stars
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://codeberg.org/jasalt/twig-templating-block/archive/master.zipFrom the readme
Installation
Clone repo in wp-content/plugins/ and install dependencies with composer install. Activate plugin and add Twig Templating block to a Block Template.
Block bindings
Block bindings provide data accessible for the twig-templating-block which can be mapped to Twig template context variables.
Example block binding registration used in further examples which could be placed in site code (a plugin or theme functions.php):
When new bindings are registered, the Site Editor needs to be reloaded. Afterwards it becomes available in Twig Templating Block attribute panel as follows.
Twig templating
Full Site Editor / Block Theme compatibility
Generally, the Twig Templating Block works can be used inside both Template Parts and Block Patterns, and render them in place for maximum compatibility with Full Site Editor and Block Theme facilities.
Template Parts
Twig function includetemplatepart($slug, $postID = null) renders a WordPress Template Part with given slug and optional PostID if it cannot be inferred from the global state.
Setting PostID is useful as example when looping inside Twig templates:
Block patterns
Similar to Template Parts, Twig function includepattern($slug