Skip to content

Instantly share code, notes, and snippets.

@fredryk
Created August 15, 2013 15:20
Show Gist options
  • Save fredryk/6241704 to your computer and use it in GitHub Desktop.
Save fredryk/6241704 to your computer and use it in GitHub Desktop.
Nice phone numbers, ugly code.
{% assign phone = shop.phone | split: '' %}{{ phone[0] }}{{ phone[1] }}{{ phone[2] }}-{{ phone[3] }}{{ phone[4] }}{{ phone[5] }}-{{ phone[6] }}{{ phone[7] }}{{ phone[8] }}{{ phone[9] }}
@Tetsuro
Copy link

Tetsuro commented Jun 5, 2014

To forloopify:

{% assign foo = shop.phone | split: '' %}
{% for i in foo %}{% if forloop.index0 == 3 or forloop.index0 == 6 %}-{% endif %}{{ foo[forloop.index0] }}{% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment