SavPhill
SavPhill

Reputation: 655

Liquid: Replace a String with an Expression

I need to replace a string with an expression. The code features three string replace scenarios. For the first two, the strings are replaced with alternate strings, which works perfectly. However for the third scenario, I need to replace the string "channel" with an expression instead: {{ booking.channel }}. My code is incorrect for the third instance only, and I have not found a solution.

<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>

Upvotes: 1

Views: 1459

Answers (1)

You need to remove the {{ }} arround booking.channel as you are already inside 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>

Upvotes: 3

Related Questions