You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+36-14
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,5 @@
1
1
# Data Transform Plugin for Pattern Lab
2
2
3
-
Since version 1.2.0 this plugin should once again work with all PatternEngines.
4
-
5
-
6
3
## Installation
7
4
8
5
To install and use the plugin run the following command in the Pattern Lab root directory:
@@ -11,7 +8,37 @@ To install and use the plugin run the following command in the Pattern Lab root
11
8
composer require aleksip/plugin-data-transform
12
9
```
13
10
14
-
For the `Attribute` object support to work properly, your Pattern Lab config file needs to have the following setting: `twigAutoescape: false`.
11
+
12
+
## Configuration options
13
+
14
+
For `Attribute` object support to work properly, your Pattern Lab `config.yml` file needs to have the following setting:
15
+
16
+
```yaml
17
+
twigAutoescape: false
18
+
```
19
+
20
+
The default values for Data Transform Plugin specific options in `config.yml` are:
21
+
22
+
```yaml
23
+
plugins:
24
+
dataTransform:
25
+
enabled: true
26
+
verbose: false
27
+
```
28
+
29
+
30
+
### Enabling and disabling the plugin
31
+
32
+
Once installed, it is possible to enable and disable Data Transform Plugin using the `enabled` setting.
33
+
34
+
35
+
### Verbose mode
36
+
37
+
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.
38
+
39
+
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.
40
+
41
+
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.
15
42
16
43
17
44
## Features
@@ -25,7 +52,7 @@ Please note that global data from the `_data` directory is considered to be patt
25
52
26
53
### Data transform functions
27
54
28
-
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!
55
+
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.
29
56
30
57
31
58
#### Include pattern files
@@ -34,7 +61,7 @@ If a value contains the name of a pattern in shorthand partials syntax, the plug
34
61
35
62
```json
36
63
{
37
-
"key": "atoms-form-element-label.html"
64
+
"key": "atoms-form-element-label-html"
38
65
}
39
66
```
40
67
@@ -44,7 +71,7 @@ Advanced syntax with support for passing variables (`with`) and disabling access
44
71
{
45
72
"key": {
46
73
"include()": {
47
-
"pattern": "atoms-form-element-label.html",
74
+
"pattern": "atoms-form-element-label-html",
48
75
"with": {
49
76
"title": "Textfield label"
50
77
},
@@ -86,7 +113,7 @@ It is also possible to include [pseudo-patterns](http://patternlab.io/docs/patte
86
113
}
87
114
```
88
115
89
-
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.
116
+
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.
90
117
91
118
92
119
#### Create Drupal `Attribute` objects
@@ -126,9 +153,4 @@ The value of `key` will be replaced with an [`Attribute` object](https://www.dru
126
153
}
127
154
```
128
155
129
-
The value of `key` will be replaced with an `Url` object. Note that in the example `attributes` will be replaced with an `Attribute` object before the `Url` object is created.
130
-
131
-
132
-
## More examples
133
-
134
-
Most features provided by this plugin are used in [Shila Drupal theme](https://github.com/aleksip/shila-drupal-theme).
156
+
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.
0 commit comments