include with array

38 views
Skip to first unread message

AM

unread,
Oct 27, 2016, 11:44:24 AM10/27/16
to Fat-Free Framework
Hey, how can I give an array to an included template?
this does not work:

<include href="_tmplt.htm" with="var1=candy,var2={{  ['apple', 'banana'] }}"/>

ved

unread,
Oct 27, 2016, 12:03:03 PM10/27/16
to Fat-Free Framework
Not sure if or how you can pass arrays using the "with" parameter on include (maybe somebody else can confirm or explain how) but the hive gets passed to any subtemplates so you should be able to use this:

$f3->set('some_array', ['val1','val2']);

And then access the array in your sub-template with:

{{ @some_array.0 }}
{{ @some_array.1 }}

xfra35

unread,
Oct 27, 2016, 3:14:34 PM10/27/16
to Fat-Free Framework
@AM it doesn't work with arrays, but you can open a Github issue and see if it can be done.

Until then, you need to pass a variable instead:

<set fruits="{{ ['apple', 'banana'] }}"/>
<include href="_tmplt.htm" with="var1=candy,var2={{ @fruits }}"/>


AM

unread,
Oct 28, 2016, 5:00:49 AM10/28/16
to Fat-Free Framework
Thanks, I did something similar:

{{@fruits = ['apple', 'banana'] }}

which also worked but I thought there would be way to write directly into the include
Reply all
Reply to author
Forward
0 new messages