|
9886ab482258e3724ed7b49ccca7f08e
|
the monday night feature request: truncate truncateby Christina - Miss Manners - 11:41PM, Jan 29, 2007 |
|
don’t ask – i just need this: to really truncate down to n characters – not n – 3 + three dots.
ok, if you really want to know: i want to do stuff with “variant.sku”, namely reduce it from 9 characters to 6 (to create a related product family containing all products characterized by the first 6 characters of the full 9-character sku string) what truncate does now is this: let’s take sku: ABC123XYZ
none of which seems terribly useful. if i’m trying to get just ABC123 - nothing more nothing less – that’s impossible. so…if you can spare a few minutes of mad coding time :)? edited despondently: oh never mind – that won’t be much use without a wildcard or a “contains”, will it? so maybe i’d be pushing my luck asking for 2 for the price of one on a monday night, what with all the goings-on on the fancy new dashboard. g’night all! Last edited 11:48PM, Jan 29, 2007 |
|
|
You could even bring the dots back with a different filter. {{ ‘ABC123XYZ’ | truncate: 3 }} = ABC123 While we are on the subject of truncating, how about truncating the front of a string. {{ ‘ABC123XYZ’ | truncate: -3 }} = 123XYZ I have a had a few times where this would have come in handy. — Last edited 12:12AM, Jan 30, 2007 |
|
|
This should be possible. the second parameter to truncate is the string it uses to truncate with. {{ string | truncate: 5, ’’ }} should do what you need. ---
Tobias Lütke
|
|
|
exactly! Thank you, Tobi!
|
danW
Shopify Advisor
12:11AM, Jan 30, 2007