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 assign include/partial to a variable?

Is it possible to do something like:

{% set test = include 'parts/flight-search-form' %}

Or even something like:

{{ str_replace(
    '[flight-search-form]',
    partial("parts/flight-search-form", ['searchType': 'simple']),
    obj.content
) }}

Second example always renders (echo's) the partial even tho if the shortcode is not present.



77.7k
Accepted
answer

This should do it ($this->view->getPartial()):

{{ str_replace('[flight-search-form]', view.getPartial('parts/flight-search-form', ['searchType':'simple']), obj.content) }}
edited Sep '17

Awesome! :)