We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt setting variable from a block (like twig's set/endset syntax), etc

Hi!

In twig it is possible do something like:

{% set foo %}
    <div id="pagination">
        ...
    </div>
{% endset %}

see: https://twig.sensiolabs.org/doc/tags/set.html

Is there a way to assign a variable from a block content in volt? If not, what a reason to disable such nice feature?

Also, where can I found full list of disabled/modified twig features?

Thank you!

First of all - volt isn't twig.

Second - well - you can just check it. Don't know if can work like this. If not - create issue on github.

I don't think there's a closing tag for set. Recently I went through the source of Volt.

First of all - volt isn't twig.

Ok, I just heard something like "volt based on twig" or so...

Second - well - you can just check it. Don't know if can work like this. If not - create issue on github.

Ofcos I tested it before asking :) Creating issue...

Thank you!

The same based as twig is based on jinja - the same concept, but syntax isn't 100% the same.

edited Sep '16

The same based as twig is based on jinja - the same concept, but syntax isn't 100% the same.

Ok, but it is not only question of the syntax. There is no such feature - not critical at all, but if there is no any reason to disable it by concept or so, I think it will be very helpful. In my case, I need to pass some html code to function, and it is much more comfy to define the string like usual volt/html block with IDE support, etc., instead of {% set var = 'huuuuuge ... string' }

Volt is based in jinja (https://jinja.pocoo.org/)

First of all - volt isn't twig.

Ok, I just heard something like "volt based on twig" or so...

Second - well - you can just check it. Don't know if can work like this. If not - create issue on github.

Ofcos I tested it before asking :) Creating issue...

Thank you!

volt currently can not extend the '{%%}' also already in use '{% set %}':

{% set sorted = [3, 1, 2]|sort %}

You can try to render partial templates and insert them into a variable.