vite-plugin-twig-drupal 1.6.3 → 1.6.4
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/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -186,6 +186,11 @@ const plugin = (options = {}) => {
|
|
|
186
186
|
return includes.reduce(
|
|
187
187
|
(queue, template) =>
|
|
188
188
|
queue.then(() => {
|
|
189
|
+
// _self is a special Twig variable referring to the current
|
|
190
|
+
// template — it is not a real file import.
|
|
191
|
+
if (template === "_self") {
|
|
192
|
+
return Promise.resolve()
|
|
193
|
+
}
|
|
189
194
|
const file = resolveFile(
|
|
190
195
|
dirname(id),
|
|
191
196
|
resolveNamespaceOrComponent(options.namespaces, template)
|
|
@@ -134,6 +134,20 @@ exports[`Basic smoke test > Should support global context and functions 1`] = `
|
|
|
134
134
|
"
|
|
135
135
|
`;
|
|
136
136
|
|
|
137
|
+
exports[`Basic smoke test > Should support import _self for recursive macros 1`] = `
|
|
138
|
+
"
|
|
139
|
+
|
|
140
|
+
<nav>
|
|
141
|
+
<ul>
|
|
142
|
+
<li><a href=\\"/home\\">Home</a></li>
|
|
143
|
+
|
|
144
|
+
<li><a href=\\"/about\\">About</a></li>
|
|
145
|
+
|
|
146
|
+
</ul>
|
|
147
|
+
</nav>
|
|
148
|
+
"
|
|
149
|
+
`;
|
|
150
|
+
|
|
137
151
|
exports[`Basic smoke test > Should support includes 1`] = `
|
|
138
152
|
"<section>
|
|
139
153
|
<h1>Include</h1>
|
package/tests/smoke.test.js
CHANGED
|
@@ -3,6 +3,7 @@ import Error from "../dist/error.js"
|
|
|
3
3
|
import ErrorInclude from "../dist/errorInclude.js"
|
|
4
4
|
import drupalFunctions from "../dist/drupalFunctions.js"
|
|
5
5
|
import Menu from "../dist/menu.js"
|
|
6
|
+
import SelfImport from "../dist/selfImport.js"
|
|
6
7
|
import { describe, expect, it } from "vitest"
|
|
7
8
|
|
|
8
9
|
describe("Basic smoke test", () => {
|
|
@@ -72,4 +73,10 @@ describe("Basic smoke test", () => {
|
|
|
72
73
|
expect(markup).toContain("All received")
|
|
73
74
|
expect(markup).toContain("pony town")
|
|
74
75
|
})
|
|
76
|
+
it("Should support import _self for recursive macros", () => {
|
|
77
|
+
const markup = SelfImport()
|
|
78
|
+
expect(markup).toContain("Home")
|
|
79
|
+
expect(markup).toContain("About")
|
|
80
|
+
expect(markup).toMatchSnapshot()
|
|
81
|
+
})
|
|
75
82
|
})
|