cayo 0.9.8 → 0.9.9
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/lib/renderer.js +9 -5
- package/package.json +1 -1
- package/test/src/pages/index.svelte +1 -1
package/lib/renderer.js
CHANGED
|
@@ -28,16 +28,20 @@ export class Renderer {
|
|
|
28
28
|
cssTag += `<style>${css.code}</style>`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// NOTE: Q: why the `() => str` for 2nd replacement arg?
|
|
32
|
+
// A: In case there's dollar signs in that there string
|
|
33
|
+
// https://stackoverflow.com/questions/9423722/string-replace-weird-behavior-when-using-dollar-sign-as-replacement
|
|
34
|
+
|
|
31
35
|
return {
|
|
32
36
|
html: this.template.html
|
|
33
37
|
// Ignore placeholders wrapped in HTML comments
|
|
34
38
|
.replace(/<!--[^]*\%cayo\.\w+\%[^]*-->/g, '')
|
|
35
39
|
// Replace placeholders in template
|
|
36
|
-
.replace('%cayo.title%', !head.includes('<title>') ? `<title>${title}</title>` : '')
|
|
37
|
-
.replace('%cayo.head%', head)
|
|
38
|
-
.replace('%cayo.body%', html)
|
|
39
|
-
.replace('%cayo.css%', cssTag)
|
|
40
|
-
.replace('%cayo.script%', `<script type="module" src="./index.js"></script>`)
|
|
40
|
+
.replace('%cayo.title%', () => !head.includes('<title>') ? `<title>${title}</title>` : '')
|
|
41
|
+
.replace('%cayo.head%', () => head)
|
|
42
|
+
.replace('%cayo.body%', () => html)
|
|
43
|
+
.replace('%cayo.css%', () => cssTag)
|
|
44
|
+
.replace('%cayo.script%', () => `<script type="module" src="./index.js"></script>`)
|
|
41
45
|
,
|
|
42
46
|
css: css,
|
|
43
47
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ I'm index howdy ok<br>
|
|
|
16
16
|
<a href="/hey/" class="red">Hey</a>
|
|
17
17
|
<a href="/some/page/" class="red">Some</a>
|
|
18
18
|
|
|
19
|
-
<Cayo name="Test"><div>Default Content</div></Cayo>
|
|
19
|
+
<Cayo name="Test" object={{ some: 'what?$staticlink$'}}><div>Default Content</div></Cayo>
|
|
20
20
|
|
|
21
21
|
<Cayo name="Cool" beans='ayo'>Whaaat</Cayo>
|
|
22
22
|
<Cayo name="Cool" beans='beeeeaaaaasnnss' />
|