Answer the question
In order to leave comments, you need to log in
Display problem in twig?
Hi!
I ran into a problem
I did some localization on the site, localization phrases are stored in the database, they are available on demand.
Phrases can contain html and some variables that are passed to the template.
I figured out the variables, I was able to shove them in, but what about html?
html is processed if the phrase is output via echo, but then the replace tweak (to substitute variables) does not work, but if the phrase is shoved through return, it’s the other way around: there is no html processing, but there are variables
And if you use return, it’s the other way around ..
Pieces of code and examples here: https://codeshare.io/21yd3B
Answer the question
In order to leave comments, you need to log in
The answer was in a conspicuous place, but I blunted
it, and after a couple of days I found the answer, but I remembered the question only now
That is, it is solved by adding a raw filter at the end
1) Write a variable substitution function for a Twig extension:
$prepareString = new Twig_SimpleFunction('prepareString', function ($str) {
return str_replace("%param1%", "Тест", $str);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question