Skip to content

Tag: templates

How to escape Twig like variables on JS

I need to escape some JS twig-like variables in a twig template, but I couldn’t find anything about how to do that. This variables are used in a js templating plugin that uses the same pattern as twig for variables which is causing the twig rendering to fail Unexpected token “punctuation” of…

How to create a link to another PHP page

I just converted some of my HTML pages to PHP pages, and I’m not that familiar with PHP. In my HTML pages, assuming it’s just a static web app, I can link to another page quite simply by playing the following anchor on the page: <a href=”go-to-this-page.html”>This is a link</a…

Undefined variables in PHP template

I use PHP as a template language in my view layer, Is it possible to make the following a little cleaner and more concise? Unfortunately, we can not even define a function for that: Answer Using @ operator is the shortest alternative. Since PHP 7 you can also use the ?? operator. Which does exactly what the @…

Smarty: unset an array index in template

I would like to do {unset($array[‘index’])} into a Smarty 3 template. Is such a syntax (or similar) supported ? After Googling and doc reading I can’t find something satisfying. Maybe I should ask for a feature request to Smarty dev team ? 🙂 Anyway, how would you do this given the currently …