2017 © Pedro Peláez
 

patternlab-plugin plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

image

aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  • Tuesday, February 13, 2018
  • by aleksip
  • Repository
  • 4 Watchers
  • 22 Stars
  • 121,516 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 5 Forks
  • 3 Open issues
  • 14 Versions
  • 16 % Grown

The README.md

Data Transform Plugin for Pattern Lab

Installation

To install and use the plugin run the following command in the Pattern Lab root directory:, (*1)

composer require aleksip/plugin-data-transform

Configuration options

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

twigAutoescape: false

The default values for Data Transform Plugin specific options in config.yml are:, (*3)

plugins:
    dataTransform:
        enabled: true
        verbose: false

Enabling and disabling the plugin

Once installed, it is possible to enable and disable Data Transform Plugin using the enabled setting., (*4)

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., (*5)

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., (*6)

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., (*7)

Features

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., (*8)

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., (*9)

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., (*10)

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:, (*11)

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

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

{
    "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., (*13)

For more information about with and only please refer to the Twig include documentation., (*14)

Include pseudo-pattern files

It is also possible to include pseudo-patterns 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:, (*15)

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

Join text values

{
    "key": {
        "join()": [
            "molecules-comment-html",
            "<div class=\"indented\">",
            "molecules-comment-html",
            "</div>",
            "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., (*16)

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., (*17)

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., (*18)

The Versions

13/02 2018

dev-develop

dev-develop https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0-or-later

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

05/02 2018

dev-master

9999999-dev https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

05/02 2018

v1.2.0

1.2.0.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0-or-later

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

22/01 2018

dev-dev

dev-dev https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

18/01 2018

v1.1.1

1.1.1.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0-or-later

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

02/01 2017

v1.1.0

1.1.0.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

24/09 2016

v1.0.2

1.0.2.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

09/08 2016

v1.0.1

1.0.1.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

13/07 2016

v1.0.0

1.0.0.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

19/05 2016

v0.10.2

0.10.2.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

11/05 2016

v0.10.1

0.10.1.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

06/05 2016

v0.10.0

0.10.0.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

 

by Aleksi Peebles

plugin drupal pattern lab

13/01 2016

v0.9.1

0.9.1.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.5.9

 

by Aleksi Peebles

plugin drupal pattern lab

12/01 2016

v0.9.0

0.9.0.0 https://github.com/aleksip/plugin-data-transform

Data Transform Plugin for Pattern Lab PHP

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.5.9

 

by Aleksi Peebles

plugin drupal pattern lab