Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pluralising with Twig
{% spaceless %}
{% if integer > 1 %}
{{ plural }}
{% else %}
{{ singular }}
{% endif %}
{% endspaceless %}
@daviddarnes

This comment has been minimized.

Copy link
Owner Author

commented Oct 31, 2017

Usage:

{% include 'pluralise.twig' with {
  integer: post.bed_count,
  plural: 'bedrooms',
  singular: 'bedroom'
} %}
@daviddarnes

This comment has been minimized.

Copy link
Owner Author

commented Oct 31, 2017

Or try this:

{{ post.bed_count }} {{ _n( 'bedroom', 'bedrooms', post.bed_count ) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.