Formatting placeholders with Liquid markup Follow

Comments

6 comments

  • Avatar
    Crawford Philleo

    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!

  • Avatar
    Bob Novak

    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

  • Avatar
    Crawford Philleo

    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!

  • Avatar
    Bob Novak

    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.

  • Avatar
    Sarah Sanders

    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?

  • Avatar
    Greg

    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!

Please sign in to leave a comment.

Powered by Zendesk