how to pass variable from page to partial

295 views Asked by At

HI I want to pass a value from my page and grab it on partial,for example bellow is example Main layout

<html lang="en">
  <head>
   .....
  </head>
  <body>
    {% partial 'a_partial' %}
  </body>
</html>

And my partial

<h1>{{ value-from-page}}</h1>

and on page I tried like bellow

function onRender()
{
    $this['value-from-page'] = "A string";
}
==

This way I am getting output on partial '0',I tried dump() on partial and its showing 'value-from-page' and its value. What is wrong am I doing?

1

There are 1 answers

0
Serena Villa On

Simply pass your variables this way:

{% partial 'a_partial' var1='var 1 content' var2='var 2 content' %}