Convert the code in twig from PHP -




i have tried convert templates plain php twig code , i'm not sure looking @ code how write following examples out in twig code. can point me in right direction?

my following php code.

<?php } if ($body_font != '' ) {  $fontpre = $body_font;  $font = str_replace("+", " ", $fontpre); ?> body {font-family:<?php echo $font ?>;} <?php } ?> 

i have tried following in twig.

{% if body_font != '' %} {% set fontpre = 'body_font' %} {% set font = fontpre|replace("+", " ") %}  body {font-family:{{ font }}; } {% endif %} 

but, doesn't work. can please help? do wrong here?

the replace filter different php function str_replace. accepts mapping keys strings should replaced values:

{% set font = fontpre|replace({"+": " "}) %} 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -