在 TWIG 短格式 if/else 语句中显示变量 HTML
Show variable within TWIG short form if/else statement with HTML
{{r.status == 'active' or 'scheduled' ? 'The order status is <a href="https://example.com/">
{{r.order}} : 'The order status is cancelled'</a>'
当使用上面的行时,它打印 {{r.order}} 而不是变量的值。如何打印该值?
您可以使用 in
operator combined with string interpolation and the raw
filter:
{{r.status in ['active', 'scheduled']
? "The order status is <a href=\"https://example.com/\">#{r.order}</a>"|raw
: 'The order status is cancelled'}}
{{r.status == 'active' or 'scheduled' ? 'The order status is <a href="https://example.com/">
{{r.order}} : 'The order status is cancelled'</a>'
当使用上面的行时,它打印 {{r.order}} 而不是变量的值。如何打印该值?
您可以使用 in
operator combined with string interpolation and the raw
filter:
{{r.status in ['active', 'scheduled']
? "The order status is <a href=\"https://example.com/\">#{r.order}</a>"|raw
: 'The order status is cancelled'}}