Skip to content

Commit 3daa687

Browse files
Custom script props utility methods
1 parent 149ad64 commit 3daa687

32 files changed

+213
-111
lines changed

docs/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ <h2 id="1.0.0-beta.8-(2022-10-25)" tabindex="-1">
104104
1.0.0-beta.8 (2022-10-25)
105105
</h2>
106106
<ul>
107-
<li>Fix merge locals with global</li>
107+
<li>Fix merge props with global</li>
108108
</ul>
109109
<h2 id="1.0.0-beta.7-(2022-10-25)" tabindex="-1">
110110
<a class="header-anchor" href="#1.0.0-beta.7-(2022-10-25)">#</a>

docs/docs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ <h2 id="1.0.0-beta.8-(2022-10-25)" tabindex="-1">
14631463
1.0.0-beta.8 (2022-10-25)
14641464
</h2>
14651465
<ul>
1466-
<li>Fix merge locals with global</li>
1466+
<li>Fix merge props with global</li>
14671467
</ul>
14681468
<h2 id="1.0.0-beta.7-(2022-10-25)" tabindex="-1">
14691469
<a class="header-anchor" href="#1.0.0-beta.7-(2022-10-25)">#</a>

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ <h2 id="1.0.0-beta.8-(2022-10-25)" tabindex="-1">
120120
1.0.0-beta.8 (2022-10-25)
121121
</h2>
122122
<ul>
123-
<li>Fix merge locals with global</li>
123+
<li>Fix merge props with global</li>
124124
</ul>
125125
<h2 id="1.0.0-beta.7-(2022-10-25)" tabindex="-1">
126126
<a class="header-anchor" href="#1.0.0-beta.7-(2022-10-25)">#</a>

docs/test.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@
4949
<h1 class="display-1 fw-bold mb-4">Playground</h1>
5050
<div class="wrapper">
5151
<div class="demo my-demo" computed:acomputed="" something="alocal">
52+
{"title":"PostHTML Components","close":true,"$slots":{},"aStringOverride":"My override string changed","anObjectOverride":{"third":"Third override item","fourth":"Fourth override item"},"computed:aComputed":true,"class":"my-demo","anObjectMerged":{"third":"Third merged item","fourth":"Fourth merged item","anObjectMerged1":{"third":"Third merged item (UPDATED?)","fourth1":"Fourth merged item"}},"post":{"title":"My post title","body":"My post body","comments":[{"id":1,"body":"My comment 1 new"},{"id":3,"body":"My comment 3"}]},"anArrayOfObjects":[{"id":1,"title":"My new title 1"},{"id":2,"title":"My new title 2","somethingnew":"New"}],"anArray":["first","third","fourth","ten"],"something":"alocal"}
53+
<div>
54+
<a href="/my-page.html">
55+
hi,
56+
<strong>fred</strong>
57+
</a>
58+
!
59+
<a href="/my-page2.html">
60+
hi,
61+
<strong>Damir</strong>
62+
</a>
63+
!
64+
</div>
65+
{"third":"Third override item","fourth":"Fourth override item","something":"Merged","again":"Again merged"}
5266
<h1>anObjectDefault</h1>
5367
<p>
5468
<strong>first</strong>
@@ -153,12 +167,12 @@ <h5>YIELD CHILD INSIDE TEST.html</h5>
153167
</div>
154168
<div class="wrapper">
155169
<div class="parent">
156-
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["Slot parent"],"source":"Slot parent","locals":{}}}
170+
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["Slot parent"],"source":"Slot parent","props":{}}}
157171
<div class="parent-content">I'm parent</div>
158172
<div class="parent-yield">
159173
<h1>Parent yield</h1>
160174
<div class="child">
161-
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["Slot child"],"source":"Slot child","locals":{}}}
175+
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["Slot child"],"source":"Slot child","props":{}}}
162176
<div class="child-content">I'm child</div>
163177
<div class="child-yield">
164178
<h1>Child yield</h1>
@@ -170,7 +184,7 @@ <h1>Child yield</h1>
170184
</div>
171185
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["\n ",{"tag":"div","attrs":{"class":"parent2-child2-slot"},"content":["\n parent2-child2 slot\n "]},"\n "],"source":"\n
172186
<div class="\&quot;parent2-child2-slot\&quot;">\n parent2-child2 slot\n</div>
173-
\n ","locals":{}},"myslot":{"filled":true,"rendered":true,"tag":"fill:myslot","attrs":{},"content":["\n SLOT CHILD INSIDE TEST.html\n "],"source":"\n SLOT CHILD INSIDE TEST.html\n ","locals":{}}}
187+
\n ","props":{}},"myslot":{"filled":true,"rendered":true,"tag":"fill:myslot","attrs":{},"content":["\n SLOT CHILD INSIDE TEST.html\n "],"source":"\n SLOT CHILD INSIDE TEST.html\n ","props":{}}}
174188

175189

176190
yes is filled
@@ -234,7 +248,7 @@ <h2 id="1.0.0-beta.8-(2022-10-25)" tabindex="-1">
234248
1.0.0-beta.8 (2022-10-25)
235249
</h2>
236250
<ul>
237-
<li>Fix merge locals with global</li>
251+
<li>Fix merge props with global</li>
238252
</ul>
239253
<h2 id="1.0.0-beta.7-(2022-10-25)" tabindex="-1">
240254
<a class="header-anchor" href="#1.0.0-beta.7-(2022-10-25)">#</a>

examples/dist/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ <h2 id="1.0.0-beta.8-(2022-10-25)" tabindex="-1">
104104
1.0.0-beta.8 (2022-10-25)
105105
</h2>
106106
<ul>
107-
<li>Fix merge locals with global</li>
107+
<li>Fix merge props with global</li>
108108
</ul>
109109
<h2 id="1.0.0-beta.7-(2022-10-25)" tabindex="-1">
110110
<a class="header-anchor" href="#1.0.0-beta.7-(2022-10-25)">#</a>

examples/dist/docs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ <h2 id="1.0.0-beta.8-(2022-10-25)" tabindex="-1">
14631463
1.0.0-beta.8 (2022-10-25)
14641464
</h2>
14651465
<ul>
1466-
<li>Fix merge locals with global</li>
1466+
<li>Fix merge props with global</li>
14671467
</ul>
14681468
<h2 id="1.0.0-beta.7-(2022-10-25)" tabindex="-1">
14691469
<a class="header-anchor" href="#1.0.0-beta.7-(2022-10-25)">#</a>

examples/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ <h2 id="1.0.0-beta.8-(2022-10-25)" tabindex="-1">
120120
1.0.0-beta.8 (2022-10-25)
121121
</h2>
122122
<ul>
123-
<li>Fix merge locals with global</li>
123+
<li>Fix merge props with global</li>
124124
</ul>
125125
<h2 id="1.0.0-beta.7-(2022-10-25)" tabindex="-1">
126126
<a class="header-anchor" href="#1.0.0-beta.7-(2022-10-25)">#</a>

examples/dist/test.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@
4949
<h1 class="display-1 fw-bold mb-4">Playground</h1>
5050
<div class="wrapper">
5151
<div class="demo my-demo" computed:acomputed="" something="alocal">
52+
{"title":"PostHTML Components","close":true,"$slots":{},"aStringOverride":"My override string changed","anObjectOverride":{"third":"Third override item","fourth":"Fourth override item"},"computed:aComputed":true,"class":"my-demo","anObjectMerged":{"third":"Third merged item","fourth":"Fourth merged item","anObjectMerged1":{"third":"Third merged item (UPDATED?)","fourth1":"Fourth merged item"}},"post":{"title":"My post title","body":"My post body","comments":[{"id":1,"body":"My comment 1 new"},{"id":3,"body":"My comment 3"}]},"anArrayOfObjects":[{"id":1,"title":"My new title 1"},{"id":2,"title":"My new title 2","somethingnew":"New"}],"anArray":["first","third","fourth","ten"],"something":"alocal"}
53+
<div>
54+
<a href="/my-page.html">
55+
hi,
56+
<strong>fred</strong>
57+
</a>
58+
!
59+
<a href="/my-page2.html">
60+
hi,
61+
<strong>Damir</strong>
62+
</a>
63+
!
64+
</div>
65+
{"third":"Third override item","fourth":"Fourth override item","something":"Merged","again":"Again merged"}
5266
<h1>anObjectDefault</h1>
5367
<p>
5468
<strong>first</strong>
@@ -153,12 +167,12 @@ <h5>YIELD CHILD INSIDE TEST.html</h5>
153167
</div>
154168
<div class="wrapper">
155169
<div class="parent">
156-
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["Slot parent"],"source":"Slot parent","locals":{}}}
170+
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["Slot parent"],"source":"Slot parent","props":{}}}
157171
<div class="parent-content">I'm parent</div>
158172
<div class="parent-yield">
159173
<h1>Parent yield</h1>
160174
<div class="child">
161-
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["Slot child"],"source":"Slot child","locals":{}}}
175+
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["Slot child"],"source":"Slot child","props":{}}}
162176
<div class="child-content">I'm child</div>
163177
<div class="child-yield">
164178
<h1>Child yield</h1>
@@ -170,7 +184,7 @@ <h1>Child yield</h1>
170184
</div>
171185
{"name":{"filled":true,"rendered":false,"tag":"fill:name","attrs":{},"content":["\n ",{"tag":"div","attrs":{"class":"parent2-child2-slot"},"content":["\n parent2-child2 slot\n "]},"\n "],"source":"\n
172186
<div class="\&quot;parent2-child2-slot\&quot;">\n parent2-child2 slot\n</div>
173-
\n ","locals":{}},"myslot":{"filled":true,"rendered":true,"tag":"fill:myslot","attrs":{},"content":["\n SLOT CHILD INSIDE TEST.html\n "],"source":"\n SLOT CHILD INSIDE TEST.html\n ","locals":{}}}
187+
\n ","props":{}},"myslot":{"filled":true,"rendered":true,"tag":"fill:myslot","attrs":{},"content":["\n SLOT CHILD INSIDE TEST.html\n "],"source":"\n SLOT CHILD INSIDE TEST.html\n ","props":{}}}
174188

175189

176190
yes is filled
@@ -234,7 +248,7 @@ <h2 id="1.0.0-beta.8-(2022-10-25)" tabindex="-1">
234248
1.0.0-beta.8 (2022-10-25)
235249
</h2>
236250
<ul>
237-
<li>Fix merge locals with global</li>
251+
<li>Fix merge props with global</li>
238252
</ul>
239253
<h2 id="1.0.0-beta.7-(2022-10-25)" tabindex="-1">
240254
<a class="header-anchor" href="#1.0.0-beta.7-(2022-10-25)">#</a>

examples/src/components/modal/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
* contentClass: any additional class for modal-content
1616
*/
1717
module.exports = {
18-
backdrop: locals.backdrop || true,
19-
keyboard: locals.backdrop === "static" || locals.keyboard === true,
20-
scrollable: locals.scrollable === true ? 'modal-dialog-scrollable' : '',
21-
centered: locals.centered === true ? 'modal-dialog-centered' : '',
22-
size: locals.size ? `modal-${locals.size}` : '',
23-
fullscreen: [true, "sm", "md", "lg", "xl", "xxl"].includes(locals.fullscreen)
24-
? (locals.fullscreen === true ? "modal-fullscreen" : `modal-fullscreen-${locals.fullscreen}-down`)
18+
backdrop: props.backdrop || true,
19+
keyboard: props.backdrop === "static" || props.keyboard === true,
20+
scrollable: props.scrollable === true ? 'modal-dialog-scrollable' : '',
21+
centered: props.centered === true ? 'modal-dialog-centered' : '',
22+
size: props.size ? `modal-${props.size}` : '',
23+
fullscreen: [true, "sm", "md", "lg", "xl", "xxl"].includes(props.fullscreen)
24+
? (props.fullscreen === true ? "modal-fullscreen" : `modal-fullscreen-${props.fullscreen}-down`)
2525
: ''
2626
};
2727
</script>
@@ -54,7 +54,7 @@
5454
</x-modal.body>
5555
</if>
5656
<if condition="$slots.footer?.filled">
57-
<x-modal.footer close="{{ $slots.footer?.locals.close }}">
57+
<x-modal.footer close="{{ $slots.footer?.props.close }}">
5858
<slot:footer></slot:footer>
5959
</x-modal.footer>
6060
</if>

examples/src/components/test/index.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<script props>
22
module.exports = {
3+
allProps: props,
4+
tplLink: template('<a href="<%= url %>">hi, <strong><%= user %></strong></a>!'),
5+
somethingMerged: merge({}, props.anObjectOverride, { something: 'Merged', again: 'Again merged'}),
36
aStringDefault: 'My default string',
47
aStringOverride: 'My default override string',
58
anObjectDefault: {
@@ -47,11 +50,19 @@
4750
}
4851
],
4952
anArray: ['first', 'second'],
50-
aComputed: locals.aComputed === true ? 'Yes' : 'No'
53+
aComputed: props.aComputed === true ? 'Yes' : 'No'
5154
};
5255
</script>
5356
<div class="wrapper">
5457
<div class="demo" attributes>
58+
{{ allProps }}
59+
<div>
60+
{{{ tplLink({ 'url': '/my-page.html', 'user': 'fred' }) }}}
61+
62+
{{{ tplLink({ 'url': '/my-page2.html', 'user': 'Damir' }) }}}
63+
</div>
64+
65+
{{ somethingMerged }}
5566
<h1>anObjectDefault</h1>
5667
<each loop="o,i in anObjectDefault">
5768
<p><strong>{{ i }}</strong>: {{ o }}</p>
@@ -97,7 +108,7 @@ <h1>aComputed</h1>
97108
<p>{{ aComputed }}</p>
98109

99110
<slot:name>
100-
{{ $slots.name.locals.aslotlocal }}
111+
{{ $slots.name.props.aslotlocal }}
101112
</slot:name>
102113
</div>
103114
</div>

0 commit comments

Comments
 (0)