string - Liquid:用表达式替换字符串
问题描述
我需要用表达式替换字符串。该代码具有三个字符串替换方案。对于前两个,字符串被替换为备用字符串,效果很好。但是对于第三种情况,我需要用一个表达式替换字符串“channel”:{{ booking.channel }}。我的代码仅对第三个实例不正确,我还没有找到解决方案。
<div class="row">
<div class="left title">Source</div>
<div class="right">{{ booking.source | replace: "app", "Front Desk" | replace: "widget", "Website" | replace: "channel", {{ booking.channel }} }}</div>
解决方案
您需要移除{{ }}
arround booking.channel
,因为您已经在 other 内部{{ }}
:
<div class="row">
<div class="left title">Source</div>
<div class="right">{{ booking.source | replace: "app", "Front Desk" | replace: "widget", "Website" | replace: "channel", booking.channel }}</div>
推荐阅读
- c# - 无法启动 Kestrel。无法绑定到已在使用的地址地址
- java - 我们可以修改cordova插件(cordova-plugin-fcm)并在我们的项目中使用吗?
- javascript - javascript setinterval 崩溃资源管理器 11 选项卡
- c# - Docusign CreateConsoleview 返回网址不起作用
- laravel - 作曲家转储自动加载什么都不做
- java - 我们可以通过map调用函数吗,在Hashmap函数的值中传递函数名
- html - 在元素两侧平均分配溢出文本
- javascript - 如何监控 Neo4j 的连接问题?
- scala - 如何使用数据框而不是 rdd 来查找曼哈顿距离度量?
- java - Junit for 循环执行计数