php - 在带有 HTML 的 TWIG 短格式 if/else 语句中显示变量
问题描述
{{r.status == 'active' or 'scheduled' ? 'The order status is <a href="https://example.com/">
{{r.order}} : 'The order status is cancelled'</a>'
当使用上面的行时,它会打印 {{r.order}} 而不是变量中的值。如何打印值?
解决方案
{{r.status in ['active', 'scheduled']
? "The order status is <a href=\"https://example.com/\">#{r.order}</a>"|raw
: 'The order status is cancelled'}}
推荐阅读
- javascript - 在 Wordpress 主页中显示带有缩略图、标题和页数限制的子页面
- android - iOS/Android NFC 标签读取安全问题
- odata - 如何在 Azure 存储资源管理器中查询“非空”或“非空”
- java - 如何转换列表
- visual-studio-2017 - 我可以在调试模式下停止 Visual Studio URL 解码命令参数吗?
- asp.net - 从 ASP.NET Core 2.0 迁移到 2.1
- c++ - Cython 就地分配 libcpp.list 的值
- python - 连接到远程服务器并使用 Python 在其中调用 API
- telegram - 如何添加内联回复按钮?
- kubernetes - 带有 --kubernetes 选项的 AWS eks 上的蛇形工作流中的局部奇点图像