-
I'm trying to figure out the best way to pass variables from one template to another, while being able to have default values for each, say I have something like this, which works fine for a few variables. {* parent.latte *}
{embed '../posts/article.latte', post_title: $post->post_title, thumbnail: $post->thumbnail}
{/embed} {* child.latte *}
{default $post_title=''}
{default $thumbnail=null} But as soon as I start to have more variables to pass the code becomes rather unwieldy {* parent.latte *}
{embed '../posts/article.latte', post_title: $post->post_title, thumbnail: $post->thumbnail, category: $post->category, tags: $post->tags, linked_articles: $post->linked_articles}
{/embed} I was wondering if it was possible to pass an object as a parameter that will get flattened in the child so that I can still make use of the {* parent.latte *}
{embed '../posts/article.latte', $post}
{/embed} But this doesn't seem to work and I can't find any other means of doing it in the documentation. Is there any way this can be achieved? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Try |
Beta Was this translation helpful? Give feedback.
Try
(expand)
https://latte.nette.org/en/syntax#toc-expand