Looking for a means to achieve twig's "embed"

Hi guys,

Twig had an embed tag, which allows for including a file that has {block}'s defined, and allowing overriding those blocks as part of that include.

Here's a simple example:

{% extends 'edit' %}

// ...lots of embed's

{% embed 'partials/form/row' with {
    item: { label: 'Location', icon: 'pin' } }
    {% block input %}
        Some custom text before the input
        {{ parent() }}
    {% endblock %}
{% endembed %}

Is there a way to achieve something similar in Volt?

Cheers, D.


You can extend the compiler to handle new functions. I used that and did not pushed it to the full limit. The features are mentioned somewhere in the middle of the Volt documentation. One option works like a keyword detector.


I used Volt compileFunction to add a function to Volt. I suspect that your usage requires compileStatement, something I have not used. compileStatement should give you the whole statement to interpret your way. The documentation is minimal. You will have to look at the code to find out what is supplied to your code.