Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove mustache in favour of handlebars #1455

Draft
wants to merge 42 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9732350
refactor: renamed and removed mustache files
mfranzke Dec 25, 2022
82d79c2
refactor: changed mustache to handlebars extensions
mfranzke Dec 25, 2022
9132377
refactor: changed mustache to handlebars extensions
mfranzke Dec 25, 2022
f5f23d2
chore: removed mustache related test
mfranzke Dec 25, 2022
b37bd08
fix: corrected those path
mfranzke Dec 25, 2022
8c001e4
refactor: removed the mustache package dependency
mfranzke Dec 26, 2022
be893ac
chore: updated engine
mfranzke Dec 26, 2022
b991e02
chore: corrected the fileending
mfranzke Dec 26, 2022
cc913fa
refactor: adapted handlebars config and docs
mfranzke Dec 26, 2022
e6fb9cd
chore: adapted structure out of newer uikit
mfranzke Dec 26, 2022
014ea88
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Dec 27, 2022
c30b78c
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
JosefBredereck Dec 28, 2022
e4ff89e
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Dec 30, 2022
98ce349
fix: incorrect path
mfranzke Dec 30, 2022
04a7c95
fix: incorrect path
mfranzke Dec 30, 2022
65b4690
fix: incorrect path
mfranzke Dec 30, 2022
74a3cad
fix: incorrect path
mfranzke Dec 30, 2022
8fb16eb
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Dec 30, 2022
7f9fd5a
chore(CI/CD): let's not install mustache engine anymore
mfranzke Dec 30, 2022
fe8329c
refactor: need to switch to the handlebars engine
mfranzke Dec 30, 2022
4835d3b
refactor: switched to hbs fileextension in configurations
mfranzke Dec 30, 2022
c78ebc6
refactor: switching from mustache engine to handlebars
mfranzke Dec 30, 2022
30be5bc
refactor(docs): switching from mustache to handlebars
mfranzke Dec 30, 2022
2c318bd
test: switching from mustache to handlebars
mfranzke Dec 30, 2022
853a493
refactor: revert the workaround out of !1256
mfranzke Dec 30, 2022
560c7ec
Update pattern_engines.js
mfranzke Dec 31, 2022
59fbbf1
Merge branch '1239-deprecate-mustache-as-default-engine' of https://g…
mfranzke Jan 1, 2023
62240b1
Restore packages/core/test/engine_mustache_tests.js
mfranzke Jan 1, 2023
bd7dfd9
refactor(test): updated syntax to handlebars
mfranzke Jan 1, 2023
764d0f2
chore: set this explicitly, aligned with the others
mfranzke Jan 3, 2023
6a14990
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Jan 3, 2023
82916a1
test: updated test case files
mfranzke Jan 4, 2023
b5a4426
test: we need to ignore our handlebars files that contain partials re…
mfranzke Jan 4, 2023
781f0b0
chore: simple comment
mfranzke Jan 4, 2023
054feb3
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Jan 8, 2023
6839abd
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Jan 9, 2023
03a16e9
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Jan 14, 2023
8ccef04
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
JosefBredereck Jan 30, 2023
8556478
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Jan 31, 2023
d983139
Merge branch 'dev' into 1239-deprecate-mustache-as-default-engine
mfranzke Apr 1, 2023
f8bf5f1
refactor: removed expandPartials
mfranzke Apr 1, 2023
80eadf7
refactor: removed leftovers
mfranzke Apr 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
- name: Setup the project
run: |
yarn run setup
npx lerna add @pattern-lab/engine-mustache --scope=@pattern-lab/core
npx lerna add @pattern-lab/engine-handlebars --scope=@pattern-lab/core
npx lerna add @pattern-lab/engine-underscore --scope=@pattern-lab/core
npx lerna add @pattern-lab/engine-liquid --scope=@pattern-lab/core
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ packages/**/annotations.js
**/_meta/_head.*
**/_meta/_foot.*
**/development-edition*/source/_patterns/**
# Ignoring handlebars template files that contain partials because of https://github.com/prettier/prettier/issues/11834
packages/core/test/**/*.hbs
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ before_install:

before_script:
- yarn run setup
- npx lerna add @pattern-lab/engine-mustache --scope=@pattern-lab/core
- npx lerna add @pattern-lab/engine-handlebars --scope=@pattern-lab/core
- npx lerna add @pattern-lab/engine-underscore --scope=@pattern-lab/core
- npx lerna add @pattern-lab/engine-liquid --scope=@pattern-lab/core
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/test/fixtures/patternlab-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
"styleguide": "node_modules/@pattern-lab/uikit-workshop/dist/",
"patternlabFiles": {
"general-header":
"node_modules/@pattern-lab/uikit-workshop/views/partials/general-header.mustache",
"node_modules/@pattern-lab/uikit-workshop/views/partials/general-header.hbs",
"general-footer":
"node_modules/@pattern-lab/uikit-workshop/views/partials/general-footer.mustache",
"node_modules/@pattern-lab/uikit-workshop/views/partials/general-footer.hbs",
"patternSection":
"node_modules/@pattern-lab/uikit-workshop/views/partials/patternSection.mustache",
"node_modules/@pattern-lab/uikit-workshop/views/partials/patternSection.hbs",
"patternSectionSubgroup":
"node_modules/@pattern-lab/uikit-workshop/views/partials/patternSectionSubgroup.mustache",
"node_modules/@pattern-lab/uikit-workshop/views/partials/patternSectionSubgroup.hbs",
"viewall":
"node_modules/@pattern-lab/uikit-workshop/views/viewall.mustache"
"node_modules/@pattern-lab/uikit-workshop/views/viewall.hbs"
},
"js": "./test/fixtures/source/js",
"images": "./test/fixtures/source/images",
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"main": "./src/index.js",
"dependencies": {
"@pattern-lab/engine-handlebars": "^6.0.0",
"@pattern-lab/engine-mustache": "^6.0.0",
"@pattern-lab/live-server": "^6.0.0",
"chalk": "4.1.0",
"chokidar": "3.5.1",
Expand Down
12 changes: 6 additions & 6 deletions packages/core/patternlab-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
"styleguide": "dist/",
"patternlabFiles": {
"general-header":
"views/partials/general-header.mustache",
"views/partials/general-header.hbs",
"general-footer":
"views/partials/general-footer.mustache",
"views/partials/general-footer.hbs",
"patternSection":
"views/partials/patternSection.mustache",
"views/partials/patternSection.hbs",
"patternSectionSubgroup":
"views/partials/patternSectionSubgroup.mustache",
"views/partials/patternSectionSubgroup.hbs",
"viewall":
"views/viewall.mustache"
"views/viewall.hbs"
},
"js": "./source/js",
"images": "./source/images",
Expand All @@ -68,7 +68,7 @@
"css": "public/css"
}
},
"patternExtension": "mustache",
"patternExtension": "hbs",
"patternStateCascade": ["inprogress", "inreview", "complete"],
"patternExportAll": false,
"patternExportDirectory": "pattern_exports",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/buildPatterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => {
//take the user defined head and foot and process any data and patterns that apply

//todo this need to be made aware of multiple ui kits
//perhaps we can check for a convention like [uikitname]_00-head.mustache, and if found, add them to patternlab.uikits[uikitname].userFoot
//perhaps we can check for a convention like [uikitname]_head.hbs, and if found, add them to patternlab.uikits[uikitname].userFoot
//then, if present, use those during compose()
const headPatternPromise = processMetaPattern(
`_head.${patternlab.config.patternExtension}`,
Expand Down
16 changes: 5 additions & 11 deletions packages/core/src/lib/decompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const logger = require('./log');
const lh = require('./lineage_hunter');
const lih = require('./list_item_hunter');
const addPattern = require('./addPattern');
const expandPartials = require('./expandPartials');

const lineage_hunter = new lh();
const list_item_hunter = new lih();
Expand All @@ -28,8 +27,6 @@ module.exports = function (pattern, patternlab, ignoreLineage) {
patternlab
);

const expandPartialPromise = expandPartials(pattern, patternlab);

let lineagePromise;

//find pattern lineage
Expand All @@ -46,12 +43,9 @@ module.exports = function (pattern, patternlab, ignoreLineage) {
addPattern(pattern, patternlab);
});

return Promise.all([
listItemPromise,
expandPartialPromise,
lineagePromise,
addPromise,
]).catch((reason) => {
logger.error(reason);
});
return Promise.all([listItemPromise, lineagePromise, addPromise]).catch(
(reason) => {
logger.error(reason);
}
);
};
78 changes: 0 additions & 78 deletions packages/core/src/lib/expandPartials.js

This file was deleted.

6 changes: 3 additions & 3 deletions packages/core/src/lib/object_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Pattern = function (
patternlab,
isPromoteToFlatPatternRun
) {
this.relPath = path.normalize(relPath); // 'atoms/global/colors.mustache'
this.relPath = path.normalize(relPath); // 'atoms/global/colors.hbs'

/**
* We expect relPath to be the path of the pattern template, relative to the
Expand All @@ -52,7 +52,7 @@ const Pattern = function (

this.fileName = pathObj.name; // 'colors'
this.subdir = pathObj.dir; // 'atoms/global'
this.fileExtension = pathObj.ext; // '.mustache'
this.fileExtension = pathObj.ext; // '.hbs'

// TODO: Remove if block when dropping ordering by prefix and keep else code
// (When we drop the info about the old ordering is deprecated)
Expand Down Expand Up @@ -343,7 +343,7 @@ Pattern.prototype = {
*/
getPatternInfo: (pathObj, patternlab, isPromoteToFlatPatternRun) => {
const info = {
// colors(.mustache) is deeply nested in atoms-/global/colors
// colors(.hbs) is deeply nested in atoms-/global/colors
patternlab: patternlab,
patternHasOwnDir: isPromoteToFlatPatternRun
? path.basename(pathObj.dir).replace(prefixMatcher, '') ===
Expand Down
14 changes: 3 additions & 11 deletions packages/core/src/lib/pattern_engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function findEnginesInConfig(config) {
// any loaded PatternEngine by addressing them like this:
//
// var PatternEngines = require('./pattern_engines/pattern_engines');
// var Mustache = PatternEngines['mustache'];
// var Handlebars = PatternEngines['handlebars'];
//
// Object.create lets us create an object with a specified prototype. We want
// this here because we would like the object's "own properties" to include
Expand All @@ -103,14 +103,6 @@ const PatternEngines = Object.create({
const enginesInConfig = findEnginesInConfig(patternLabConfig);

if (enginesInConfig) {
// Quick fix until we've removed @pattern-lab/engine-mustache, starting with https://github.com/pattern-lab/patternlab-node/issues/1239 & https://github.com/pattern-lab/patternlab-node/pull/1455
// @TODO: Remove after removing @pattern-lab/engine-mustache dependency
enginesInConfig.mustache = enginesInConfig.mustache || {};
enginesInConfig.mustache.package =
enginesInConfig.mustache.package || '@pattern-lab/engine-mustache';
enginesInConfig.mustache.extensions =
enginesInConfig.mustache.extensions || 'mustache';

// Try loading each of the configured pattern engines
// eslint-disable-next-line guard-for-in
for (const name in enginesInConfig) {
Expand Down Expand Up @@ -239,9 +231,9 @@ const PatternEngines = Object.create({
}
}

// otherwise, assume it's a plain mustache template string and act
// otherwise, assume it's a plain handlebars template string and act
// accordingly
return 'mustache';
return 'handlebars';
},

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/addPattern_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tap.test(
//arrange
const patternlab = util.fakePatternLab(patterns_dir);

var pattern = new Pattern('test/bar.mustache');
var pattern = new Pattern('test/bar.hbs');
pattern.extendedTemplate = 'barExtended';
pattern.template = 'bar';

Expand All @@ -35,7 +35,7 @@ tap.test(
//arrange
const patternlab = util.fakePatternLab(patterns_dir);

var pattern = new Pattern('test/bar.mustache');
var pattern = new Pattern('test/bar.hbs');
pattern.extendedTemplate = undefined;
pattern.template = 'bar';

Expand Down
17 changes: 0 additions & 17 deletions packages/core/test/files/_meta/_head.mustache

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blue

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
red

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yellow

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
black

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
grey

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
white

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>These aren't the patterns you are looking for.</div>

This file was deleted.

4 changes: 4 additions & 0 deletions packages/core/test/files/_patterns/test/a.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<b>a</b>
{{#if a}}
<i>a!</i>
{{/if}}
4 changes: 0 additions & 4 deletions packages/core/test/files/_patterns/test/a.mustache

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{> test-styled-atom additionalClasses="test_1" }}

This file was deleted.

5 changes: 5 additions & 0 deletions packages/core/test/files/_patterns/test/b.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<b>b</b>
{{#if b }}
<i>b!</i>
{{/if }}
{{> test-a a=true }}
5 changes: 0 additions & 5 deletions packages/core/test/files/_patterns/test/b.mustache

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="test_group">
{{#listItems.two}}
{{> test-styled-atom }}
{{> test-styled-atom:test_1 }}
{{> test-styled-atom additionalClasses="test_1" }}
{{> test-styled-atom}}
{{/listItems.two}}
</div>
6 changes: 6 additions & 0 deletions packages/core/test/files/_patterns/test/bookend-params.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="test_group">
{{> test-styled-atom }}
{{> test-styled-atom additionalClasses="test_2" message="2" }}
{{> test-styled-atom additionalClasses="test_3" message="3" }}
{{> test-styled-atom }}
</div>

This file was deleted.

6 changes: 6 additions & 0 deletions packages/core/test/files/_patterns/test/bookend.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="test_group">
{{> test-styled-atom }}
{{> test-styled-atom additionalClasses="test_2" }}
{{> test-styled-atom additionalClasses="test_3" }}
{{> test-styled-atom}}
</div>
Loading