We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to call {{variable}} inside {{ {{variable}} }}

hi ,

i have some trouble in view.

i save html data in database, then i get that data. i want echo that data as view. in other side in my data there is volt syntax (ex. {{name}}). i want this name will echo real value not {{name}}. ex. name is mario, so {{name}} will be mario.

i have made script like this, but it doesnt work, i need somebody help me.

$view->start(); $view->setVar('name', 'mario valentino'); $view->setContent($data['content']); $view->finish(); echo $view->getContent();

note : $data['content'] include volt syntax, i want all volt syntax do what it should do like echo variable.

hope i get the answer.

thanks

mario valentino



128
edited Jan '15

Hi mario.

Have you tried using this:

$this->view->setVar("name", "mario");

instead of instantiating new \Phalcon\MVC\VIew.

In your .volt file, just {{ name }}

edited Jan '15

actually im not using traditional way like u. all volt syntax ex, {{ variable }} is getting from database, not setting manual.

ex : (above is changed be come this one)

$content['data'] = "{{widget('widgetName')}}"; //this data is taken from database, this is just example.

$view->setVar("data", $content['data']);

note : in $content['data'] there is a volt syntax that i was defined.

so when i call {{data}} in volt, all volt tag executing ex. {{widget('widgetName')}} automatically;

can someone help me ? please phalcon



33.8k

You could try removing the brackets from the DB record ({{ and }}). But I don't believe that it will work because you are returning a string all the time.