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
Post a Comment