cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR] Volt support "with"

Open x51xxx opened this issue 13 years ago • 4 comments

Add possibility additional variables by passing them after the "with" keyword:

{# the foo template will have access to the variables from the current context and the foo one #}
{% include 'foo' with ['foo': 'bar'] %}

{% set vars = ['foo': 'bar'] %}
{% include 'foo' with vars %}

Add possibility disable access to the context by appending the only keyword:

{# only the foo variable will be accessible #}
{% include 'foo' with ['foo': 'bar'] only %}

{# no variable will be accessible #}
{% include 'foo' only %}

x51xxx avatar Dec 24 '12 22:12 x51xxx

I am not sure I understand this - i.e. the value of it. What do we need to achieve that with will help with?

niden avatar Mar 12 '13 15:03 niden

It will help develop universal partials and restrict namespace by anologii http://twig.sensiolabs.org/doc/tags/include.html

x51xxx avatar Mar 13 '13 14:03 x51xxx

The 'include' statement in Volt has a different behavior, it includes the requested view in the view where the 'include' was made. This reduces the number of read files increasing performance. In summary, a 'include' joins every included file into the parent one.

We could implement this in the partial function which is in fact dynamical.

http://docs.phalconphp.com/en/latest/reference/volt.html#partial-vs-include

ghost avatar Mar 13 '13 18:03 ghost

This is implemented in 1.2.0, thanks

ghost avatar Jun 07 '13 05:06 ghost