Closed
Description
I am using Pattern Lab Node v1.2.2
on Mac
, using the gulp
configuration.
Expected Behavior
When a pattern is included, it should inherit from the following in order:
- The includer's (similarly named) json file
- The included pattern's (similarly named) json file -- supplementing what does not already exist from 1
- data.json -- supplementing what does not already exist from 1 or 2
We are creating an enterprise-level site with a lot of pattern reuse and inclusion in other patterns. A lot of the data is shared, but requires tweaks to certain attributes. This has caused a huge amount of bloat in data.json, in order to allow for the inheritance of shared data.
Actual Behavior
When a pattern is included, it inherits from:
- The includer's (similarly named) json file
- data.json -- supplementing what does not already exist from 1
Steps to Reproduce
Mustaches & JSON
_data/data.json
{
"test": {
"title": "data.json Title",
"data": "data.json Data"
},
}
_patterns/00-atoms/test.mustache
<p>
Title: {{test.title}}<br />
Data: {{test.data}}
</p>
_patterns/00-atoms/test.json
{
"test": {
"title": "test.json Title",
"data": "test.json Data"
}
}
_patterns/01-molecules/test-molecule.mustache
<p>This is a molecule that contains test</p>
<p>Molecule Data: {{molecule-test}}</p>
{{> atoms-test }}
_patterns/01-molecules/test-molecule.json
{
"molecule-test": "Molecule Test Content"
}
_patterns/01-molecules/test-molecule~with-title.json
{
"test": {
"title": "test-molecule~with-title.json Title"
}
}
Result
?p=atoms-test: Actual & Expected
<p>
Title: test.json Title<br>
Data: test.json Data
</p>
?p=molecules-test-molecule: Actual
<p>This is a molecule that contains test</p>
<p>Molecule Data: Molecule Test Content</p>
<p>
Title: data.json Title<br>
Data: data.json Data
</p>
?p=molecules-test-molecule-with-title: Actual
<p>This is a molecule that contains test</p>
<p>Molecule Data: Molecule Test Content</p>
<p>
Title: test-molecule~with-title.json Title<br>
Data: data.json Data
</p>
?p=molecules-test-molecule: Expected
<p>This is a molecule that contains test</p>
<p>Molecule Data: Molecule Test Content</p>
<p>
Title: test.json Title<br>
Data: test.json Data
</p>
?p=molecules-test-molecule-with-title: Expected
<p>This is a molecule that contains test</p>
<p>Molecule Data: Molecule Test Content</p>
<p>
Title: test-molecule~with-title.json Title<br>
Data: test.json Data
</p>