Getting variable from Snippet


I am using the wonderful feature to pass variables into a snippet with snippet('my_snippet', array('var' => $var)) but now I’d love to go the other way round and fetch a variable that was generated inside the snippet.
How is this done?


Have a look at this post: Undefined variable in snippet

how can I pass multiple vars into a snippet?

Best regards,

Snippets take an array of variables:

<?php snippet('mysnippet', array(
    'title' => $title,
    'page' => $page,
    'color' => 'red'

Hi texnixe,
I tried to seperate variables with an comma but it doesn’t work.
Mmh, than I have to go in the debugging :smile: ;

I’m sure that it works, though, because I’ve already done it. You can test it with a simple example, e.g. define two simple string variables in a template:


$color = "blue";
$blur = "strong";

snippet('test', array('color'=>$color, 'blur' => $blur));


Snippet test.php

echo $color;
echo $blur;

I guess there’s something else that doesn’t work as it should …

I had a mistake in my code. Thanks for your exlaining!

Good night.