PHPackages                             aleksip/plugin-data-transform - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. aleksip/plugin-data-transform

ActivePatternlab-plugin[Utility &amp; Helpers](/categories/utility)

aleksip/plugin-data-transform
=============================

Data Transform Plugin for Pattern Lab PHP

v1.4.0(6y ago)34897.4k—1.4%10[5 issues](https://github.com/aleksip/plugin-data-transform/issues)3GPL-2.0-or-laterPHPPHP &gt;=5.5.9

Since Jan 12Pushed 6y ago3 watchersCompare

[ Source](https://github.com/aleksip/plugin-data-transform)[ Packagist](https://packagist.org/packages/aleksip/plugin-data-transform)[ Docs](https://github.com/aleksip/plugin-data-transform)[ RSS](/packages/aleksip-plugin-data-transform/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (16)Used By (3)

Data Transform Plugin for Pattern Lab
=====================================

[](#data-transform-plugin-for-pattern-lab)

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

[](#installation)

To install and use the plugin run the following command in the Pattern Lab root directory:

```
composer require aleksip/plugin-data-transform
```

Configuration options
---------------------

[](#configuration-options)

For `Attribute` object support to work properly, your Pattern Lab `config.yml` file needs to have the following setting:

```
twigAutoescape: false
```

The default values for Data Transform Plugin specific options in `config.yml` are:

```
plugins:
    dataTransform:
        enabled: true
        verbose: false
```

### Enabling and disabling the plugin

[](#enabling-and-disabling-the-plugin)

Once installed, it is possible to enable and disable Data Transform Plugin using the `enabled` setting.

### Verbose mode

[](#verbose-mode)

Occasionally it might happen that there is a problem with a data file, and PHP notices and/or warnings with long stack traces are displayed when Pattern Lab is generated. In a large project it can be difficult to find the problematic data file, but turning on Data Transform Plugin's verbose mode using the `verbose` setting can help.

In verbose mode Data Transform plugin reports each pattern it processes and all data transform functions performed. It also suppresses regular PHP error messages and reports about errors in an easier to read way.

Important note: due to the way verbose mode is implemented, it might not work if other plugins that interact with the Twig `Environment` object are used.

Features
--------

[](#features)

### Pattern-specific data file support for included patterns

[](#pattern-specific-data-file-support-for-included-patterns)

Pattern Lab core only supports global data files and a pattern-specific data file for the main pattern. This plugin adds pattern-specific data file support for included patterns. This feature works with the include function provided by this plugin with all PatternEngines and also with regular includes in template files with Twig PatternEngine.

Please note that global data from the `_data` directory is considered to be pattern-specific data and will overwrite data inherited from a parent pattern. If you want to override data of an included pattern you can use the `with` keyword.

### Data transform functions

[](#data-transform-functions)

Currently the plugin provides four transform functions for the data read by Pattern Lab. The examples provided are in JSON but Pattern Lab supports YAML too.

#### Include pattern files

[](#include-pattern-files)

If a value contains the name of a pattern in shorthand partials syntax, the plugin will replace the value with the rendered pattern:

```
{
    "key": "atoms-form-element-label-html"
}
```

Advanced syntax with support for passing variables (`with`) and disabling access to the default data (`only`):

```
{
    "key": {
        "include()": {
            "pattern": "atoms-form-element-label-html",
            "with": {
                "title": "Textfield label"
            },
            "only": true
        }
    }
}
```

In both examples the value of `key` will replaced with the rendered pattern.

For more information about `with` and `only` please refer to the [Twig `include` documentation](https://twig.symfony.com/doc/2.x/tags/include.html).

#### Include pseudo-pattern files

[](#include-pseudo-pattern-files)

It is also possible to include [pseudo-patterns](http://patternlab.io/docs/pattern-pseudo-patterns.html) using the shorthand partials syntax, by replacing the tilde (~) with a dash (-). So for example the pseudo-pattern `shila-card.html~variant.json` can be included like so:

```
{
    "key": "molecules-shila-card-html-variant"
}
```

#### Join text values

[](#join-text-values)

```
{
    "key": {
        "join()": [
            "molecules-comment-html",
            "",
            "molecules-comment-html",
            "",
            "molecules-comment-html"
        ]
    }
}
```

The value of `key` will be replaced with the joined strings. Note that in the example `molecules-comment-html` is the name of a pattern in shorthand partials syntax. These will be replaced with the rendered pattern before the join.

#### Create Drupal `Attribute` objects

[](#create-drupal-attribute-objects)

```
{
    "key": {
        "Attribute()": {
            "id": ["edit-submit"],
            "type": ["submit"],
            "value": ["Submit"],
            "class": ["button", "button-primary"]
        }
    }
}
```

The value of `key` will be replaced with an [`Attribute` object](https://www.drupal.org/node/2513632).

#### Create Drupal `Url` objects

[](#create-drupal-url-objects)

```
{
    "key": {
        "Url()": {
            "url": "http://example.com",
            "options": {
                "attributes": {
                    "Attribute()": {
                        "class": ["link"]
                    }
                }
            }
        }
    }
}
```

The value of `key` will be replaced with an `Url` object. Note that in the example the value of `attributes` will be replaced with an `Attribute` object before the `Url` object is created.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 90.3% 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

Every ~103 days

Recently: every ~151 days

Total

14

Last Release

2437d ago

Major Versions

v0.10.2 → v1.0.02016-07-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/dac531c15d447cbc140ea8fda8f6632fe9caf8a7e3dba90bca46c1cbf46bd9fc?d=identicon)[aleksip](/maintainers/aleksip)

---

Top Contributors

[![aleksip](https://avatars.githubusercontent.com/u/1181287?v=4)](https://github.com/aleksip "aleksip (56 commits)")[![charlotte17](https://avatars.githubusercontent.com/u/16827021?v=4)](https://github.com/charlotte17 "charlotte17 (2 commits)")[![gambry](https://avatars.githubusercontent.com/u/11092878?v=4)](https://github.com/gambry "gambry (2 commits)")[![EvanLovely](https://avatars.githubusercontent.com/u/569699?v=4)](https://github.com/EvanLovely "EvanLovely (1 commits)")[![stmh](https://avatars.githubusercontent.com/u/319208?v=4)](https://github.com/stmh "stmh (1 commits)")

---

Tags

drupalpattern-labphppluginplugindrupalpattern lab

### Embed Badge

![Health badge](/badges/aleksip-plugin-data-transform/health.svg)

```
[![Health](https://phpackages.com/badges/aleksip-plugin-data-transform/health.svg)](https://phpackages.com/packages/aleksip-plugin-data-transform)
```

###  Alternatives

[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[drupal/core-composer-scaffold

A flexible Composer project scaffold builder.

5341.9M446](/packages/drupal-core-composer-scaffold)[pattern-lab/edition-drupal-standard

Standard Edition of Pattern Lab for Drupal.

12419.1k](/packages/pattern-lab-edition-drupal-standard)[drupal/core-project-message

Adds a message after Composer installation.

2122.6M172](/packages/drupal-core-project-message)[pattern-lab/plugin-data-inheritance

Data inheritance based on pattern lineage for Pattern Lab.

13103.9k1](/packages/pattern-lab-plugin-data-inheritance)

PHPackages © 2026

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