PHPackages                             jorisnoo/craft-twig-helpers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. jorisnoo/craft-twig-helpers

ActiveCraft-module[Templating &amp; Views](/categories/templating)

jorisnoo/craft-twig-helpers
===========================

Shared Twig helpers for Craft CMS with config-based extensibility.

1.0.0(1mo ago)0381↓45%MITPHPPHP ^8.2CI passing

Since May 12Pushed 1mo agoCompare

[ Source](https://github.com/jorisnoo/craft-twig-helpers)[ Packagist](https://packagist.org/packages/jorisnoo/craft-twig-helpers)[ RSS](/packages/jorisnoo-craft-twig-helpers/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Craft Twig Helpers
==================

[](#craft-twig-helpers)

A [Craft CMS](https://craftcms.com/) module that provides shared Twig helpers with config-based extensibility. Ships with a set of built-in functions and filters, and allows you to register your own via a config file.

Features
--------

[](#features)

- Built-in Twig functions: `placeholderImage`
- Built-in Twig filters: `hasTransparency`, `trimEmptyParagraphs`
- Built-in Twig tag: `{% minify %}` for HTML minification
- Register custom filters, functions, globals, and tests via config
- Supports Craft 4 and Craft 5

Requirements
------------

[](#requirements)

- Craft CMS ^4.0.0 or ^5.0.0
- PHP ^8.2

Installation
------------

[](#installation)

```
composer require jorisnoo/craft-twig-helpers
```

Register the module in your `config/app.php`:

```
return [
    'modules' => [
        'twig-helpers' => \Noo\CraftTwigHelpers\TwigHelpers::class,
    ],
    'bootstrap' => ['twig-helpers'],
];
```

Configuration
-------------

[](#configuration)

Create a `config/twig-helpers.php` file in your Craft project to register custom helpers:

```
use Noo\CraftTwigHelpers\config\TwigHelpersConfig;

return TwigHelpersConfig::create()
    ->filters([
        'myFilter' => fn (string $value) => strtoupper($value),
    ])
    ->functions([
        'myFunction' => fn () => 'Hello, world!',
    ])
    ->globals([
        'siteName' => 'My Site',
    ])
    ->tests([
        'even' => fn (int $value) => $value % 2 === 0,
    ]);
```

Built-in Helpers
----------------

[](#built-in-helpers)

### Functions

[](#functions)

#### `placeholderImage(config)`

[](#placeholderimageconfig)

Generates a data URI for a placeholder SVG image.

```

```

### Filters

[](#filters)

#### `hasTransparency`

[](#hastransparency)

Checks whether an Asset image has transparency.

```
{% if asset|hasTransparency %}
    {# handle transparent image #}
{% endif %}
```

#### `trimEmptyParagraphs`

[](#trimemptyparagraphs)

Strips empty `` tags from the beginning and end of HTML content. Useful for cleaning up CKEditor output that adds filler paragraphs.

Handles ``, ``, `&nbsp;`, non-breaking space characters, and `` tags with attributes (e.g. `data-cke-filler`).

```
{{ entry.text|trimEmptyParagraphs }}
```

### Tags

[](#tags)

#### `{% minify %}`

[](#-minify-)

Minifies the wrapped HTML by stripping comments, collapsing whitespace, and removing unnecessary spaces around block-level elements. Content inside ``, ``, ``, and `` tags is preserved.

Minification is automatically disabled when `devMode` is `true`.

```
{% minify %}

    ...

        ...

{% endminify %}
```

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0440b6ac994d5566a2ef5886fbac104a73f8458e70dbd20085e241ab0f647e0d?d=identicon)[jorgenoo](/maintainers/jorgenoo)

---

Top Contributors

[![jorisnoo](https://avatars.githubusercontent.com/u/5810772?v=4)](https://github.com/jorisnoo "jorisnoo (14 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jorisnoo-craft-twig-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/jorisnoo-craft-twig-helpers/health.svg)](https://phpackages.com/packages/jorisnoo-craft-twig-helpers)
```

###  Alternatives

[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

292943.4k27](/packages/craftcms-feed-me)[verbb/formie

The most user-friendly forms plugin for Craft.

100387.6k57](/packages/verbb-formie)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

53675.5k16](/packages/solspace-craft-freeform)[wbrowar/guide

A CMS Guide for Craft CMS.

6154.6k1](/packages/wbrowar-guide)[verbb/footnotes

Adds a footnotes feature to CKEditor fields and Twig templates.

213.5k](/packages/verbb-footnotes)[froala/craft-froala-wysiwyg

Craft 3 CMS plugin for Froala WYSIWYG HTML Rich Text Editor.

1719.1k](/packages/froala-craft-froala-wysiwyg)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
