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

feat: STRF-11523 Add the ability to use Handlebar Partial Blocks #1167

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion lib/template-assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const dynamicComponentRegex = /\{\{\s*?dynamicComponent\s*(?:'|")([_|\-|a-zA-Z0-
const includeRegex = /{{2}>\s*([_|\-|a-zA-Z0-9/]+)[^{]*?}{2}/g;
const pathStringRegex = /^["'].+["']$/;
const packageMarker = 'external/';
const partialBlock = '@partial-block';

/**
* indicates if a template source is a node modules dependency
Expand Down Expand Up @@ -169,7 +170,9 @@ function getTemplatePaths(templatesFolder, templates, options, callback) {
while (match !== null) {
[, partialPath] = match;
if (!templatePaths.includes(partialPath)) {
matches.push(partialPath);
if (partialPath !== partialBlock) {
matches.push(partialPath);
}
}
match = partialRegex.exec(content);
}
Expand Down
172 changes: 98 additions & 74 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"engines": {
"node": ">=16.0.0 <19.0.0",
"npm": ">=8.0.0 <10.0.0"
"npm": ">=8.0.0"
},
"scripts": {
"lint": "eslint . && prettier --check . --ignore-unknown",
Expand Down
6 changes: 6 additions & 0 deletions test/_mocks/themes/valid/templates/components/c.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Here is the list:
{{#> components/ul }}
{{> components/li text="Item 1" link="item_link_1"}}
{{> components/li text="Item 2" link="item_link_2"}}
{{> components/li text="Item 3" link="item_link_3"}}
{{/components/ul}}
3 changes: 3 additions & 0 deletions test/_mocks/themes/valid/templates/components/li.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li>
<a href="{{link}}">{{text}}</a>
</li>
3 changes: 3 additions & 0 deletions test/_mocks/themes/valid/templates/components/ul.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ul>
{{> @partial-block }}
<ul>
Loading
Loading