Formatting placeholders with Liquid markup

Have more questions? Submit a request

22 Comments

  • Crawford Philleo
    Comment actions Permalink

    Hello! How would I capitalize each word in a string with a liquid filter in zendesk?

     

    Example: bob jones --> Bob Jones

     

    Example: martha's flower shop --> Martha's Flower Shop

     

    Thanks!

    0
  • Bob Novak
    Comment actions Permalink

    Hi Crawford - you would use the same capitalize filter that we mentioned earlier in the comments:

    https://github.com/shopify/liquid/wiki/liquid-for-designers#standard-filters

    0
  • Crawford Philleo
    Comment actions Permalink

    Hi Bob, thanks but this isn't working for me.

     

    I have a custom field, so I'm formatting my placeholder in a macro like this:

     

    {{ticket.ticket_field_<field ID> | capitalize}}

     

    This custom field is a Text field, and what this filter does is capitalize only the first word in the text string. If the text in that field is all caps, it will lower-case the string, and capitalize the first word only. Help!

    0
  • Bob Novak
    Comment actions Permalink

    Ah I guess you're right! Looks like that documentation is inaccurate. This resource says it only capitalizes the first word: https://help.shopify.com/themes/liquid/filters/string-filters#capitalize

    This is a bit more complicated, but you can do something using a for loop. There is a post on this page that describes it and you don't need a plugin:

    http://stackoverflow.com/questions/21315732/capitalize-first-letter-of-each-word-with-liquid-syntax

    I was able to get this to work on my account, but you'll want to play around with it a bit to make sure the formatting is how you want.

    0
  • Sarah Sanders
    Comment actions Permalink

    I'd like to control the output text when using a URL placeholder.

    I know that you can control normal link content by formatting it like this:

    [Text you see](URL link)

    This doesn't work with the placeholder. Is there a way to accomplish this?

    -1
  • Greg
    Comment actions Permalink

    Hi Sarah! That's a good question and to properly answer this, I'll need to see the payload that you're using in the placeholder. I'm going to open up a ticket for you and you'll get a notification of that in a bit. We can work through this from there!

    0
  • Thijm Post
    Comment actions Permalink

    I would like to use {{ticket.requester.last_name}}‍ in the salutation of an Macro. For example:

    Dear Sir / Madam {{ticket.requester.last_name}}‍,

    But if someone sends us a e-mail, and they have not setup their first and last name, then this tag places everything before the @ symbol of the e-mailadres. For example:

    Dear Sir / Madam thecompanyname,

    What I would want to do:

    • If last_name is set, then add space+lastname.
    • If last_name not is set, then add nothing.

    This wil result in :

    Dear Sir / Madam Lastname,

    or

    Dear Sir / Madam,

    How can this be done?

    0
  • Keith @ Zendesk
    Comment actions Permalink

    Hey Thijm,

     

    Unfortunately we don't have anything that can work like that. For us in Support, sometimes the Macro really doesn't line up with the information we have, so we'll need to change it manually.  I've send your feedback on to Product though so they're aware of this need.

    Thanks!

    0
  • Charles Wood
    Comment actions Permalink

    It looks like many sites that use Liquid will implement a json filter, to convert an element into JSON. As Liquid is available in trigger payloads, this would be really helpful. Any idea if something like this exists, or is planned?

    0
  • Ed Hass
    Comment actions Permalink

    I am using a placeholder to capture an email address but need to remove the hyperlink when its sent to the external email target. I have tried using strip_html but this doesn't work, do you have any suggestions?

    0
  • Jessie Schutz
    Comment actions Permalink

    Hi Ed!

    I see that Daniel pulling you into a ticket for this. He'll get you taken care of!

    0
  • Patrick Bosmans
    Comment actions Permalink

    Hello Charles,

    Liquid is a custom tool that administrators can use to adjust the communications that Zendesk sends to end-users.  From the research that I have done on other sites, this filter was a custom install on their end to have this behavior exhibited.

    From what I found, this is not a feature that we will be adding to our system in the near future.  However, I would definitely suggest posting this in our product feedback forum.  Our Dev team regularly goes through looking for new posts for feature requests to see what we can accomodate and add to the system.

    Sincerely,

    Patrick | Tier 1 Customer Advocate

    0
  • Brianna McBride
    Comment actions Permalink

    I'm trying to build a macro that says if our custom dropdown field "Town/Release Required" is "Little Elm" or "Denton County", place the corresponding dynamic content into the macro.

    For instance, if the Town/Release Required field is selected to "Little Elm", I would like our dynamic content named {{dc.little_elm}} to present when I apply the macro to the reply. However, if the Town/Release Required field is selected to "Denton County" I would like our dynamic content named {{dc.denton_county}} to present in the macro.

    0
  • Stephen Fusco
    Comment actions Permalink

    Hey Brianna, 

    Thanks for reaching out to us! You should be able to use liquid markup in your macro to determine which dynamic content element is added on your ticket. This article should help you understand the logic and syntax behind how that'd work: Using Liquid markup to support multiple languages in automations, macros, and triggers

    I see you already have a ticket open with us on this topic so if you need any additional help setting that up for your individual use case please let us know there :) 

    1
  • Brianna McBride
    Comment actions Permalink

    Hi, Stephen! I've tried the link & I really truly have tried my best to figure it out on my own, but I would LOVE help on my individual case. How do I go about doing/getting that? 

    Thanks! 

    Brianna 

     

    0
  • Jessie Schutz
    Comment actions Permalink

    Hi Brianna!

    Since you already have a ticket open, our support team will be able to help with your individual situation there. :)

    0
  • Jolshock
    Comment actions Permalink

    Hello!

    I am trying to modify a notification trigger. I want the requester to receive an email when a new public comment is added. The format should be:

    Most recent comment formatted using rich text object

    followed by

    All public comments as formatted objects EXCLUDING the most recent comment. 

     

    This is what I use now, but it displays the most recent comment twice. Once in rich text and once as formatted object. Is there something I can do to the formatted object to exclude the most recent comment?

    {% for comment in ticket.comments limit:1 offset:0 %}
    {{comment.value_rich}}
    {% for attachment in comment.attachments %}

    Attachments:
    {{attachment.filename}}
    {{attachment.url}}

    {% endfor %}

    {% endfor %}

    -----------------------------------------------------------------------------------------
    {{ticket.public_comments_formatted}}

     

    Thanks!

    1
  • Hamilton
    Comment actions Permalink

    Hi Thijm,

    Not sure if you managed to come right in the end with your greeting message for your ticket requester but we use a string that I created which does something very similar to what you want and I've adapted it to what you're looking for.

    -------------

    Dear Sir/Madam {% if ticket.requester.last_name }} {{ticket.requester.last_name|capitalize}}​ {% else %} {% endif%},

    -------------

    This can either be used in a trigger when sending a welcome/update email and you can use it in the first line of your macro. It's entirely up to you

    I hope I've understood your  request correctly and that this actually accomplishes what you wanted, albeit a year on.

    Give it a go and let us know how it went

    0
  • Jessie Schutz
    Comment actions Permalink

    Thanks for sharing your solution, Hamilton!

    1
  • Hamilton
    Comment actions Permalink

    Let us see if it works first 😉

    0
  • Kalle Windefalk
    Comment actions Permalink
    Hi! 

    I'm extracting a string of text from a custom multi-line field with a placehlder in a macro. 

    The text is put together when it arrives in the body of the message.

    Placeholder in zendesk is: {{ticket.requester.custom_fields.computer_info}}

    The text in the multi-line text field is displayed as so:

    Name: LT-Laptop1

    Serial: 1234567

    Model: HP ABC123

    but when I pull the text with the placeholder it's displayed like this in the message body:

    Name: LT-Laptop1Serial: 1234567Model: HP ABC123

    How can I "extract" the labels Name, Serial and Model (with the following info) to separate lines?

     

    0
  • Dan Cooper
    Comment actions Permalink

    Hi Kalle, 

    If you are willing to go through your fields and update them to have a comma at the end, you could potentially use the split filter to add new lines in place of the commas.  In short you'd turn these into an array and parse out each item onto its own line.

    There is a good example here about how to use split to parse out each array item into a new line. 

    You may also be able to use replace to parse out your values, I was trying to come up with a good replace with your example, but ran out of time. 

    I tried your placeholder example and adapted it to a few variations of this but wasn't able to get a line break to work, but I'll share this in concept form for you to think about:

    {{ticket.requester.custom_fields.computer_info | replace: 'Serial','\nSerial'}}

    Hope this gets you on the right track.  If you solve for it, share what you find as it's a very interesting idea I'm sure others would love. 

    0

Please sign in to leave a comment.

Powered by Zendesk