Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.



38.6k
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 29d ago

Awesome! :)