Created
October 31, 2017 13:11
-
-
Save daviddarnes/5e142eff7a77270c5f93d456e040a9bf to your computer and use it in GitHub Desktop.
Pluralising with Twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% spaceless %} | |
{% if integer > 1 %} | |
{{ plural }} | |
{% else %} | |
{{ singular }} | |
{% endif %} | |
{% endspaceless %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, here is my implementation via a twig filter, a bit inspired by AngularJS's ngPluralize filter.
My gist: https://gist.github.com/tasiot/b85aa195c622f4c15c095a2cae8ccfc2