我正在尝试翻译一个包含HTML标签的字符串,但是Laravel刀片以纯文本格式返回我。
{{ _i('The <b>%s</b> referral program is a great way to spread the word of this great service and to earn even more money with your short links! Refer friends and receive %s of their earnings for life!', 'gano.com', '20%') }}
结果:
The <b>gano.com</b> referral program is a great way to spread the word of this great service and to earn even more money with your short links! Refer friends and receive 20% of their earnings for life!
我正在使用以下Laravel软件包。
答案 0 :(得分:2)
您可以尝试以下两个选项:
{!! _i('The <b>%s</b> referral program is a great way to spread the word of this great service and to earn even more money with your short links! Refer friends and receive %s of their earnings for life!', 'gano.com', '20%') !!}
{!!html_entity_decode(_i('The <b>%s</b> referral program is a great way to spread the word of this great service and to earn even more money with your short links! Refer friends and receive %s of their earnings for life!', 'gano.com', '20%'))!!}
两者都适合您。
答案 1 :(得分:0)
您可以像这样呈现html标签:
{!! 'this text will be <b>bold</b>.' !!}
输出:此文本将为粗体。
Laravel使用{{ }}
来转义标签,以防止XSS攻击。
但是无论如何,您都需要在变量内呈现html标签,您可以使用{!! !!}