Add a Leading Zero with a number field I have a number field used for episode numbers and I would like to automatically add a leading zero when the number is less than 10. I have this working with a conditional but it seems inefficient. Is there a twig filter that I don't know about that does this?

{% if entry.episodeNumber &lt; "10" %}
    {% set episodeNumber = '0' ~ entry.episodeNumber %}
{% else %}
    {% set episodeNumber = entry.episodeNumber %}
{% endif %}


The above works but seems overly long to accomplish what should be a simple task.
There aren't any filters built in to Craft (or Twig) that does this, but your {% if %} conditional could be trimmed down to a single-line ternary operation:

{% set episodeNumber = (entry.episodeNumber &lt; 10 ? '0') ~ entry.episodeNumber %}


or even

&lt;span&gt;{{ (entry.episodeNumber &lt; 10 ? '0') ~ entry.episodeNumber }}&lt;/span&gt;