TwigExtensions by justb3a

Allows customizing twig, e.g. add extensions

WARNING: This repository is no longer maintained

This repository will not be updated. The repository will be kept available in read-only mode.

ProcessWire Twig Extensions

Allows customizing twig, e.g. add extensions.



After installation go to module settings and enable/disable the required extensions/functions.


Twig Extensions Repository


Adds the following extensions/helpers:


  • Debug // only if debug mode is turned on

    {# dump - dumps information about a template variable #}
    {{ dump('Hello World!') }}
    string(12) "Hello World!"
  • Intl

    {# localizeddate - format dates into a localized string representating the date #}
    {{ "now"|date_modify("-2 day")|localizeddate('medium', 'none', 'en') }}
    Mar 8, 2017
    {# localizednumber - format numbers into a localized string representating the number #}
    {{ '50.5555'|localizednumber('decimal', 'default', 'en') }}
    {# localizedcurrency - format a currency value into a localized string #}
    {{ '50.5555'|localizedcurrency('EUR', 'en') }}
  • Text

    {# truncate - cut off a string after limit is reached #}
    {{ 'Hello World!'|truncate(5) }}
    {# wordwrap - split your text in lines with equal length #}
    {{ 'Hello World!'|wordwrap(4) }}
    o Wo
  • Array

    {# shuffle - randomize an array #}
    {{ [ 'one', 'two', 'three', 'four' ]|shuffle }}
    [ 'two', 'three', 'one', 'four' ]
  • Date

    {# time_diff - difference between two dates #}
    {% set start = "now"|date_modify("-2 day") %}
    {% set end = "now"|date_modify("+2 day") %}
    {{ start|time_diff }}
    2 days ago
    {{ start|time_diff(end) }}
    4 days ago


  • fileExists: Checks whether a file or directory exists.

    {% if file_exists(config.paths.assets ~ 'img/filename.png') %}
      The file exists.
    {% else %}
      The file does not exist.
    {% endif %}
  • widont: Prevent widow in string

    • in typesetting a widow is a very short line (one word or the end of an hyphenated word), which is separated from the rest of the paragraph. It's considered as poor typography because it leaves too much white space.
    {{ 'Add Widont Helper'|widont }}
    'Add Widont Helper'


  • kalongFeature: A frontend styleguide development toolkit
    • Kalong is a collection/combination of different tools, to help you get started creating your own frontend styleguide, with easy reusable components
    • it is based on Fractal and a collection of custom gulp-tasks to get you started fast

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Twitter updates

  • ProcessWire 3.0.185 (dev) core updates, plus new Session Allow module— More
    17 September 2021
  • Three new ProcessWire Textformatter modules: Find/Replace, Markdown in Markup, and Emoji— More
    3 September 2021
  • This week we have a new master version released after a year in the making. With nearly 40 pull requests, hundreds of new additions and more than 100 issue reports resolved, this new version has a ton of great new stuff— More
    27 August 2021

Latest news

  • ProcessWire Weekly #384
    In the 384th issue of ProcessWire Weekly we'll cover the latest core updates, introduce a new module called Session Allow, and highlight a new site of the week. Read on! / 18 September 2021
  • ProcessWire 3.0.184 new master/main version
    This week we have a new master/main version released after a full year in the making. As you might imagine, this new version has a ton of great new stuff and we’ll try to cover much of it here.
    Blog / 27 August 2021
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani