@maizzle/framework 3.7.2 → 4.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/nodejs.yml +28 -29
- package/bin/maizzle +3 -0
- package/package.json +91 -84
- package/src/commands/build.js +32 -0
- package/src/commands/serve.js +156 -0
- package/src/functions/plaintext.js +5 -0
- package/src/functions/render.js +5 -0
- package/src/generators/output/to-disk.js +120 -79
- package/src/generators/output/to-string.js +7 -8
- package/src/generators/plaintext.js +49 -52
- package/src/generators/postcss.js +29 -0
- package/src/generators/posthtml.js +66 -60
- package/src/generators/tailwindcss.js +116 -84
- package/src/index.js +14 -160
- package/src/transformers/{attribute-to-style.js → attributeToStyle.js} +0 -0
- package/src/transformers/baseUrl.js +69 -0
- package/src/transformers/{extra-attributes.js → extraAttributes.js} +0 -0
- package/src/transformers/filters/defaultFilters.js +126 -0
- package/src/transformers/filters/index.js +55 -0
- package/src/transformers/index.js +63 -57
- package/src/transformers/{inline.js → inlineCss.js} +1 -14
- package/src/transformers/minify.js +1 -1
- package/src/transformers/{posthtml-mso.js → posthtmlMso.js} +0 -0
- package/src/transformers/prettify.js +16 -9
- package/src/transformers/{prevent-widows.js → preventWidows.js} +0 -0
- package/src/transformers/{remove-attributes.js → removeAttributes.js} +1 -1
- package/src/transformers/{remove-inline-bgcolor.js → removeInlineBackgroundColor.js} +1 -1
- package/src/transformers/{remove-inline-sizes.js → removeInlineSizes.js} +0 -0
- package/src/transformers/removeInlinedSelectors.js +70 -0
- package/src/transformers/removeUnusedCss.js +40 -0
- package/src/transformers/{replace-strings.js → replaceStrings.js} +0 -0
- package/src/transformers/{safe-class-names.js → safeClassNames.js} +8 -2
- package/src/transformers/shorthandInlineCSS.js +19 -0
- package/src/transformers/sixHex.js +33 -0
- package/src/transformers/{url-params.js → urlParameters.js} +0 -0
- package/src/utils/helpers.js +2 -8
- package/test/expected/posthtml/component.html +13 -0
- package/test/expected/{inheritance.html → posthtml/extend-template.html} +2 -2
- package/test/expected/posthtml/fetch.html +5 -0
- package/test/expected/posthtml/layout.html +3 -0
- package/test/expected/transformers/atimport-in-style.html +15 -0
- package/test/expected/transformers/base-url.html +99 -0
- package/test/expected/transformers/filters.html +81 -0
- package/test/expected/transformers/preserve-transform-css.html +36 -0
- package/test/expected/useConfig.html +9 -0
- package/test/fixtures/basic.html +9 -9
- package/test/fixtures/posthtml/component.html +19 -0
- package/test/fixtures/{inheritance.html → posthtml/extend-template.html} +7 -7
- package/test/fixtures/posthtml/fetch.html +9 -0
- package/test/fixtures/posthtml/layout.html +11 -0
- package/test/fixtures/transformers/atimport-in-style.html +11 -0
- package/test/fixtures/transformers/base-url.html +101 -0
- package/test/fixtures/transformers/filters.html +87 -0
- package/test/fixtures/transformers/preserve-transform-css.html +25 -0
- package/test/fixtures/useConfig.html +9 -0
- package/test/stubs/components/component.html +5 -0
- package/test/stubs/data.json +14 -0
- package/test/stubs/layouts/basic.html +1 -0
- package/test/stubs/{layout.html → layouts/full.html} +0 -0
- package/test/stubs/{layout-basic.html → layouts/template.html} +5 -5
- package/test/stubs/post.css +6 -0
- package/test/stubs/tailwind/content-source.html +1 -0
- package/test/stubs/tailwind/tailwind.css +3 -0
- package/test/stubs/template.html +10 -10
- package/test/stubs/templates/1.html +1 -1
- package/test/stubs/templates/2.test +1 -0
- package/test/test-config.js +19 -19
- package/test/test-misc.js +8 -8
- package/test/test-postcss.js +8 -0
- package/test/test-posthtml.js +72 -0
- package/test/test-tailwindcss.js +117 -0
- package/test/test-todisk.js +142 -49
- package/test/test-tostring.js +148 -124
- package/test/test-transformers.js +510 -320
- package/xo.config.js +22 -19
- package/src/transformers/base-image-url.js +0 -9
- package/src/transformers/remove-unused-css.js +0 -20
- package/src/transformers/six-hex.js +0 -10
- package/src/transformers/transform.js +0 -24
- package/test/expected/transformers/base-image-url.html +0 -7
- package/test/fixtures/transformers/base-image-url.html +0 -7
- package/test/stubs/templates/2.html +0 -1
- package/test/stubs/templates/3.mzl +0 -1
- package/test/test-tailwind.js +0 -73
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<!-- Append -->
|
|
2
|
+
<div>testing append</div>
|
|
3
|
+
<!-- Prepend -->
|
|
4
|
+
<div>testing prepend</div>
|
|
5
|
+
|
|
6
|
+
<!-- Uppercase -->
|
|
7
|
+
<div>TEST</div>
|
|
8
|
+
<!-- Lowercase -->
|
|
9
|
+
<div>test</div>
|
|
10
|
+
<!-- Capitalize -->
|
|
11
|
+
<div>Test</div>
|
|
12
|
+
|
|
13
|
+
<!-- Ceil -->
|
|
14
|
+
<div>2</div>
|
|
15
|
+
<!-- Floor -->
|
|
16
|
+
<div>1</div>
|
|
17
|
+
<!-- Round -->
|
|
18
|
+
<div>1235</div>
|
|
19
|
+
|
|
20
|
+
<!-- Escape -->
|
|
21
|
+
<div>"&'<></div>
|
|
22
|
+
<!-- Escape Once -->
|
|
23
|
+
<div>1 < 2 & 3</div>
|
|
24
|
+
|
|
25
|
+
<!-- lstrip -->
|
|
26
|
+
<div>test </div>
|
|
27
|
+
<!-- rstrip -->
|
|
28
|
+
<div> test</div>
|
|
29
|
+
<!-- trim -->
|
|
30
|
+
<div>test</div>
|
|
31
|
+
|
|
32
|
+
<!-- Minus -->
|
|
33
|
+
<div>1.02</div>
|
|
34
|
+
<!-- Plus -->
|
|
35
|
+
<div>5.02</div>
|
|
36
|
+
<!-- Times -->
|
|
37
|
+
<div>12.08</div>
|
|
38
|
+
<!-- Divide -->
|
|
39
|
+
<div>6.04</div>
|
|
40
|
+
<!-- Modulo -->
|
|
41
|
+
<div>1</div>
|
|
42
|
+
|
|
43
|
+
<!-- Newline to br -->
|
|
44
|
+
<div><br> test<br> test<br></div>
|
|
45
|
+
<!-- Strip newlines -->
|
|
46
|
+
<div> test test</div>
|
|
47
|
+
|
|
48
|
+
<!-- Remove -->
|
|
49
|
+
<div>I sted to see the t through the </div>
|
|
50
|
+
<!-- Remove First -->
|
|
51
|
+
<div>I sted to see the train through the rain</div>
|
|
52
|
+
|
|
53
|
+
<!-- Replace -->
|
|
54
|
+
<div>testestest</div>
|
|
55
|
+
<!-- Replace First -->
|
|
56
|
+
<div>testest</div>
|
|
57
|
+
|
|
58
|
+
<!-- Size -->
|
|
59
|
+
<div>33</div>
|
|
60
|
+
|
|
61
|
+
<!-- Slice -->
|
|
62
|
+
<div>est</div>
|
|
63
|
+
<!-- Slice with endIndex -->
|
|
64
|
+
<div>tes</div>
|
|
65
|
+
|
|
66
|
+
<!-- Truncate -->
|
|
67
|
+
<div>Ground control to...</div>
|
|
68
|
+
<!-- Truncate (do nothing) -->
|
|
69
|
+
<div>Ground control to</div>
|
|
70
|
+
<!-- Truncate with custom ellipsis -->
|
|
71
|
+
<div>Ground control to no one</div>
|
|
72
|
+
|
|
73
|
+
<!-- Truncate words -->
|
|
74
|
+
<div>Ground control...</div>
|
|
75
|
+
<!-- Truncate words with custom ellipsis -->
|
|
76
|
+
<div>Ground control over and out</div>
|
|
77
|
+
|
|
78
|
+
<!-- URL decode -->
|
|
79
|
+
<div>'Stop!' said Fred</div>
|
|
80
|
+
<!-- URL encode -->
|
|
81
|
+
<div>user%40example.com</div>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<style data-embed="">.block {
|
|
5
|
+
display: block !important;
|
|
6
|
+
} .inline {
|
|
7
|
+
display: inline !important;
|
|
8
|
+
} .table {
|
|
9
|
+
display: table !important;
|
|
10
|
+
} .contents {
|
|
11
|
+
display: contents !important;
|
|
12
|
+
} .truncate {
|
|
13
|
+
overflow: hidden !important;
|
|
14
|
+
text-overflow: ellipsis !important;
|
|
15
|
+
white-space: nowrap !important;
|
|
16
|
+
} .uppercase {
|
|
17
|
+
text-transform: uppercase !important;
|
|
18
|
+
} .lowercase {
|
|
19
|
+
text-transform: lowercase !important;
|
|
20
|
+
} .capitalize {
|
|
21
|
+
text-transform: capitalize !important;
|
|
22
|
+
} div {
|
|
23
|
+
text-transform: uppercase;
|
|
24
|
+
} [data-ogsc] .inexistent {
|
|
25
|
+
color: #ef4444;
|
|
26
|
+
} div > u + .body .gmail-android-block {
|
|
27
|
+
display: block !important;
|
|
28
|
+
} u + #body a {
|
|
29
|
+
color: inherit;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
32
|
+
</head>
|
|
33
|
+
<body>
|
|
34
|
+
<div>test</div>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
package/test/fixtures/basic.html
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
</html>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>test></title>
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<div>test</div>
|
|
8
|
+
</body>
|
|
9
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<component
|
|
2
|
+
src="test/stubs/components/component.html"
|
|
3
|
+
text="Example"
|
|
4
|
+
locals='{
|
|
5
|
+
"foo": "bar"
|
|
6
|
+
}'
|
|
7
|
+
>
|
|
8
|
+
Variable from page: [[ page.env ]]
|
|
9
|
+
|
|
10
|
+
<component
|
|
11
|
+
src="test/stubs/components/component.html"
|
|
12
|
+
text="Nested component"
|
|
13
|
+
locals='{
|
|
14
|
+
"foo": "bar (nested)"
|
|
15
|
+
}'
|
|
16
|
+
>
|
|
17
|
+
Variable from page (nested): [[ page.env ]]
|
|
18
|
+
</component>
|
|
19
|
+
</component>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
---
|
|
2
|
-
template: second
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
<extends src="test/stubs/template.html">
|
|
6
|
-
<block name="button">Child in second.html</block>
|
|
7
|
-
</extends>
|
|
1
|
+
---
|
|
2
|
+
template: second
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<extends src="test/stubs/template.html">
|
|
6
|
+
<block name="button">Child in second.html</block>
|
|
7
|
+
</extends>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<style>
|
|
4
|
+
.test {
|
|
5
|
+
background-image: url('image.jpg');
|
|
6
|
+
background: url('image.jpg');
|
|
7
|
+
background-image: url('https://preserve.me/image.jpg');
|
|
8
|
+
background: url('https://preserve.me/image.jpg');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.test-2 {
|
|
12
|
+
background-image: url("image.jpg");
|
|
13
|
+
background: url("image.jpg");
|
|
14
|
+
background-image: url("https://preserve.me/image.jpg");
|
|
15
|
+
background: url("https://preserve.me/image.jpg");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.test-3 {
|
|
19
|
+
background-image: url(image.jpg);
|
|
20
|
+
background: url(image.jpg);
|
|
21
|
+
background-image: url(https://preserve.me/image.jpg);
|
|
22
|
+
background: url(https://preserve.me/image.jpg);
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
|
|
27
|
+
<body>
|
|
28
|
+
<img src="test.jpg">
|
|
29
|
+
<img src="https://example.com/test.jpg">
|
|
30
|
+
|
|
31
|
+
<img src="image1.jpg" srcset="image1-HD.jpg 2x,image1-phone.jpg 100w">
|
|
32
|
+
|
|
33
|
+
<img src="https://example.com/image2.jpg" srcset="https://example.com/image2-HD.jpg 2x, https://example.com/image2-phone.jpg 100w">
|
|
34
|
+
|
|
35
|
+
<picture>
|
|
36
|
+
<source media="(max-width: 799px)" srcset="elva-480w-close-portrait.jpg">
|
|
37
|
+
<source media="(min-width: 800px)" srcset="elva-800w.jpg">
|
|
38
|
+
<img src="elva-800w.jpg" alt="...">
|
|
39
|
+
</picture>
|
|
40
|
+
|
|
41
|
+
<video width="250" poster="flower.jpg">
|
|
42
|
+
<source src="media/flower.webm" type="video/webm">
|
|
43
|
+
<source src="https://example.tv/media/flower.mp4" type="video/mp4">
|
|
44
|
+
<track default kind="captions" srclang="en" src="media/tracks/friday.vtt">
|
|
45
|
+
</video>
|
|
46
|
+
|
|
47
|
+
<audio src="media/sample.mp3">
|
|
48
|
+
Fallback content
|
|
49
|
+
</audio>
|
|
50
|
+
|
|
51
|
+
<embed type="video/webm" src="media/flower.mp4" width="250" height="200">
|
|
52
|
+
|
|
53
|
+
<iframe width="300" height="200" src="embed.html"></iframe>
|
|
54
|
+
|
|
55
|
+
<input type="image" src="image.jpg" alt="">
|
|
56
|
+
|
|
57
|
+
<script src="javascript.js"></script>
|
|
58
|
+
|
|
59
|
+
<div>
|
|
60
|
+
<!--[if mso]>
|
|
61
|
+
<v:image xmlns:v="urn:schemas-microsoft-com:vml" src="image.jpg" style="width:600px;height:400px;" />
|
|
62
|
+
<v:rect fill="false" stroke="false" style="position:absolute;width:600px;height:400px;">
|
|
63
|
+
<v:textbox inset="0,0,0,0"><div><![endif]-->
|
|
64
|
+
<div>test</div>
|
|
65
|
+
<!--[if mso]></div></v:textbox></v:rect><![endif]-->
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<!--[if mso]>
|
|
69
|
+
<v:image src="image-2.jpg" xmlns:v="urn:schemas-microsoft-com:vml" style="width:600px;height:400px;" />
|
|
70
|
+
<![endif]-->
|
|
71
|
+
|
|
72
|
+
<!--[if mso]>
|
|
73
|
+
<v:image xmlns:v="urn:schemas-microsoft-com:vml" src="https://example.com/image-3.jpg" style="width:600px;height:400px;" />
|
|
74
|
+
<![endif]-->
|
|
75
|
+
|
|
76
|
+
<table>
|
|
77
|
+
<tr>
|
|
78
|
+
<td background="image.png" bgcolor="#7bceeb" width="120" height="92" valign="top">
|
|
79
|
+
<!--[if gte mso 9]>
|
|
80
|
+
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:120px;height:92px;">
|
|
81
|
+
<v:fill type="tile" src="image.png" color="#7bceeb" />
|
|
82
|
+
<v:textbox inset="0,0,0,0">
|
|
83
|
+
<![endif]-->
|
|
84
|
+
<div>test</div>
|
|
85
|
+
<!--[if gte mso 9]>
|
|
86
|
+
</v:textbox>
|
|
87
|
+
</v:rect>
|
|
88
|
+
<![endif]-->
|
|
89
|
+
</td>
|
|
90
|
+
</tr>
|
|
91
|
+
</table>
|
|
92
|
+
|
|
93
|
+
<!--[if mso]>
|
|
94
|
+
<v:fill type="tile" src="image.png" color="#7bceeb" />
|
|
95
|
+
<![endif]-->
|
|
96
|
+
|
|
97
|
+
<!--[if mso]>
|
|
98
|
+
<v:fill type="tile" src="https://example.com/image.png" color="#7bceeb" />
|
|
99
|
+
<![endif]-->
|
|
100
|
+
</body>
|
|
101
|
+
</html>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<!-- Append -->
|
|
2
|
+
<div append="ing append">test</div>
|
|
3
|
+
<!-- Prepend -->
|
|
4
|
+
<div prepend="test">ing prepend</div>
|
|
5
|
+
|
|
6
|
+
<!-- Uppercase -->
|
|
7
|
+
<div uppercase>test</div>
|
|
8
|
+
<!-- Lowercase -->
|
|
9
|
+
<div lowercase>TEST</div>
|
|
10
|
+
<!-- Capitalize -->
|
|
11
|
+
<div capitalize>test</div>
|
|
12
|
+
|
|
13
|
+
<!-- Ceil -->
|
|
14
|
+
<div ceil>1.2</div>
|
|
15
|
+
<!-- Floor -->
|
|
16
|
+
<div floor>1.2</div>
|
|
17
|
+
<!-- Round -->
|
|
18
|
+
<div round>1234.567</div>
|
|
19
|
+
|
|
20
|
+
<!-- Escape -->
|
|
21
|
+
<div escape>"&'<></div>
|
|
22
|
+
<!-- Escape Once -->
|
|
23
|
+
<div escape-once>1 < 2 & 3</div>
|
|
24
|
+
|
|
25
|
+
<!-- lstrip -->
|
|
26
|
+
<div lstrip> test </div>
|
|
27
|
+
<!-- rstrip -->
|
|
28
|
+
<div rstrip> test </div>
|
|
29
|
+
<!-- trim -->
|
|
30
|
+
<div trim> test </div>
|
|
31
|
+
|
|
32
|
+
<!-- Minus -->
|
|
33
|
+
<div minus="2">3.02</div>
|
|
34
|
+
<!-- Plus -->
|
|
35
|
+
<div plus="2">3.02</div>
|
|
36
|
+
<!-- Times -->
|
|
37
|
+
<div times="2">6.04</div>
|
|
38
|
+
<!-- Divide -->
|
|
39
|
+
<div divide-by="2">12.08</div>
|
|
40
|
+
<!-- Modulo -->
|
|
41
|
+
<div modulo="2">3</div>
|
|
42
|
+
|
|
43
|
+
<!-- Newline to br -->
|
|
44
|
+
<div newline-to-br>
|
|
45
|
+
test
|
|
46
|
+
test
|
|
47
|
+
</div>
|
|
48
|
+
<!-- Strip newlines -->
|
|
49
|
+
<div strip-newlines>
|
|
50
|
+
test
|
|
51
|
+
test
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<!-- Remove -->
|
|
55
|
+
<div remove="rain">I strained to see the train through the rain</div>
|
|
56
|
+
<!-- Remove First -->
|
|
57
|
+
<div remove-first="rain">I strained to see the train through the rain</div>
|
|
58
|
+
|
|
59
|
+
<!-- Replace -->
|
|
60
|
+
<div replace="t|test">test</div>
|
|
61
|
+
<!-- Replace First -->
|
|
62
|
+
<div replace-first="t|test">test</div>
|
|
63
|
+
|
|
64
|
+
<!-- Size -->
|
|
65
|
+
<div size>This string is 33 characters long</div>
|
|
66
|
+
|
|
67
|
+
<!-- Slice -->
|
|
68
|
+
<div slice="1">test</div>
|
|
69
|
+
<!-- Slice with endIndex -->
|
|
70
|
+
<div slice="0,-1">test</div>
|
|
71
|
+
|
|
72
|
+
<!-- Truncate -->
|
|
73
|
+
<div truncate="17">Ground control to Major Tom.</div>
|
|
74
|
+
<!-- Truncate (do nothing) -->
|
|
75
|
+
<div truncate="17">Ground control to</div>
|
|
76
|
+
<!-- Truncate with custom ellipsis -->
|
|
77
|
+
<div truncate="17, no one">Ground control to Major Tom.</div>
|
|
78
|
+
|
|
79
|
+
<!-- Truncate words -->
|
|
80
|
+
<div truncate-words="2">Ground control to Major Tom.</div>
|
|
81
|
+
<!-- Truncate words with custom ellipsis -->
|
|
82
|
+
<div truncate-words="2, over and out">Ground control to Major Tom.</div>
|
|
83
|
+
|
|
84
|
+
<!-- URL decode -->
|
|
85
|
+
<div url-decode>%27Stop%21%27+said+Fred</div>
|
|
86
|
+
<!-- URL encode -->
|
|
87
|
+
<div url-encode>user@example.com</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<style tailwindcss preserve>
|
|
5
|
+
div {
|
|
6
|
+
@apply uppercase;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
[data-ogsc] .inexistent {
|
|
10
|
+
color: #ef4444;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div > u + .body .gmail-android-block {
|
|
14
|
+
display: block !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
u + #body a {
|
|
18
|
+
color: inherit;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<div>test</div>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<block name="template"></block>
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
---
|
|
2
|
-
template: base
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
<block name="template"></block>
|
|
1
|
+
---
|
|
2
|
+
template: base
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<block name="template"></block>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="hidden"></div>
|
package/test/stubs/template.html
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
---
|
|
2
|
-
template: first
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
<extends src="test/stubs/
|
|
6
|
-
<block name="template">
|
|
7
|
-
Parent
|
|
8
|
-
<block name="button">Child in first.html</block>
|
|
9
|
-
</block>
|
|
10
|
-
</extends>
|
|
1
|
+
---
|
|
2
|
+
template: first
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<extends src="test/stubs/layouts/template.html">
|
|
6
|
+
<block name="template">
|
|
7
|
+
Parent
|
|
8
|
+
<block name="button">Child in first.html</block>
|
|
9
|
+
</block>
|
|
10
|
+
</extends>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
html
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
test
|
package/test/test-config.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const test = require('ava')
|
|
2
|
-
const Config = require('../src/generators/config')
|
|
3
|
-
|
|
4
|
-
test('returns the merged config', async t => {
|
|
5
|
-
const config = await Config.getMerged('maizzle-ci')
|
|
6
|
-
t.is(config.env, 'maizzle-ci')
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('throws if env name is not a string', async t => {
|
|
10
|
-
await t.throwsAsync(async () => {
|
|
11
|
-
await Config.getMerged(false)
|
|
12
|
-
}, {instanceOf: TypeError, message: `env name must be a string, received boolean(false)`})
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
test('throws if a config could not be loaded for the specified environment', async t => {
|
|
16
|
-
await t.throwsAsync(async () => {
|
|
17
|
-
await Config.getMerged('fake')
|
|
18
|
-
}, {instanceOf: Error, message: `could not load config.fake.js`})
|
|
19
|
-
})
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const Config = require('../src/generators/config')
|
|
3
|
+
|
|
4
|
+
test('returns the merged config', async t => {
|
|
5
|
+
const config = await Config.getMerged('maizzle-ci')
|
|
6
|
+
t.is(config.env, 'maizzle-ci')
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('throws if env name is not a string', async t => {
|
|
10
|
+
await t.throwsAsync(async () => {
|
|
11
|
+
await Config.getMerged(false)
|
|
12
|
+
}, {instanceOf: TypeError, message: `env name must be a string, received boolean(false)`})
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('throws if a config could not be loaded for the specified environment', async t => {
|
|
16
|
+
await t.throwsAsync(async () => {
|
|
17
|
+
await Config.getMerged('fake')
|
|
18
|
+
}, {instanceOf: Error, message: `could not load config.fake.js`})
|
|
19
|
+
})
|
package/test/test-misc.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const test = require('ava')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const {requireUncached} = require('../src/utils/helpers')
|
|
4
|
-
|
|
5
|
-
test('requires an uncached module', t => {
|
|
6
|
-
const helpers = requireUncached(path.resolve(process.cwd(), 'src/utils/helpers'))
|
|
7
|
-
t.is(typeof helpers.requireUncached, 'function')
|
|
8
|
-
})
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const {requireUncached} = require('../src/utils/helpers')
|
|
4
|
+
|
|
5
|
+
test('requires an uncached module', t => {
|
|
6
|
+
const helpers = requireUncached(path.resolve(process.cwd(), 'src/utils/helpers'))
|
|
7
|
+
t.is(typeof helpers.requireUncached, 'function')
|
|
8
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const PostCSS = require('../src/generators/postcss')
|
|
3
|
+
|
|
4
|
+
test('throws on processing error', async t => {
|
|
5
|
+
await t.throwsAsync(async () => {
|
|
6
|
+
await PostCSS.process(null, {})
|
|
7
|
+
}, {instanceOf: Error, message: 'PostCSS processing failed'})
|
|
8
|
+
})
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const Maizzle = require('../src')
|
|
3
|
+
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
|
|
7
|
+
const readFile = (dir, filename) => fs.promises
|
|
8
|
+
.readFile(path.join(__dirname, dir, `${filename}.html`), 'utf8')
|
|
9
|
+
.then(html => html.trim())
|
|
10
|
+
|
|
11
|
+
const fixture = file => readFile('fixtures', file)
|
|
12
|
+
const expected = file => readFile('expected', file)
|
|
13
|
+
|
|
14
|
+
const renderString = (string, options = {}) => Maizzle.render(string, options).then(({html}) => html)
|
|
15
|
+
|
|
16
|
+
test('layouts', async t => {
|
|
17
|
+
const source = await fixture('posthtml/layout')
|
|
18
|
+
|
|
19
|
+
const html = await renderString(source, {maizzle: {env: 'maizzle-ci'}})
|
|
20
|
+
|
|
21
|
+
t.is(html.trim(), await expected('posthtml/layout'))
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('inheritance when extending a template', async t => {
|
|
25
|
+
const source = await fixture('posthtml/extend-template')
|
|
26
|
+
let html = await renderString(source)
|
|
27
|
+
|
|
28
|
+
html = html.replace(/[^\S\r\n]+$/gm, '').trim()
|
|
29
|
+
|
|
30
|
+
t.is(html, await expected('posthtml/extend-template'))
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('components', async t => {
|
|
34
|
+
const source = await fixture('posthtml/component')
|
|
35
|
+
const options = {
|
|
36
|
+
maizzle: {
|
|
37
|
+
env: 'maizzle-ci',
|
|
38
|
+
build: {
|
|
39
|
+
components: {
|
|
40
|
+
expressions: {
|
|
41
|
+
delimiters: ['[[', ']]']
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const html = await renderString(source, options)
|
|
49
|
+
|
|
50
|
+
t.is(html.trim(), await expected('posthtml/component'))
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('fetch component', async t => {
|
|
54
|
+
const source = await fixture('posthtml/fetch')
|
|
55
|
+
const options = {
|
|
56
|
+
maizzle: {
|
|
57
|
+
env: 'maizzle-ci',
|
|
58
|
+
build: {
|
|
59
|
+
posthtml: {
|
|
60
|
+
expressions: {
|
|
61
|
+
delimiters: ['[[', ']]']
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let html = await renderString(source, options)
|
|
69
|
+
html = html.replace(/[^\S\r\n]+$/gm, '')
|
|
70
|
+
|
|
71
|
+
t.is(html.trim(), await expected('posthtml/fetch'))
|
|
72
|
+
})
|