vite-plugin-twig-drupal 1.2.0 → 1.2.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-twig-drupal",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Provides a ⚡️ Vite plugin to transform 🌱 Twig into HTML with a 💧 Drupal flavour",
5
5
  "keywords": [
6
6
  "Vite",
package/src/index.js CHANGED
@@ -194,6 +194,8 @@ const plugin = (options = {}) => {
194
194
 
195
195
  ${functions}
196
196
 
197
+ addDrupalExtensions(Twig);
198
+
197
199
  // Disable caching.
198
200
  Twig.cache(false);
199
201
 
@@ -1,5 +1,10 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
+ exports[`Basic smoke test > Should recognise default Drupal functions 1`] = `
4
+ "
5
+ <p>Functions work</p>"
6
+ `;
7
+
3
8
  exports[`Basic smoke test > Should support global context and functions 1`] = `
4
9
  "<section>
5
10
  <h1>Include</h1>
@@ -0,0 +1,2 @@
1
+ {{ attach_library('drupal/library') }}
2
+ <p>Functions work</p>
@@ -1,6 +1,7 @@
1
1
  import Markup from "../dist/test.js"
2
2
  import Error from "../dist/error.js"
3
3
  import ErrorInclude from "../dist/errorInclude.js"
4
+ import drupalFunctions from "../dist/drupalFunctions.js"
4
5
  import Menu from "../dist/menu.js"
5
6
  import { describe, expect, it } from "vitest"
6
7
 
@@ -35,4 +36,9 @@ describe("Basic smoke test", () => {
35
36
  expect(markup).toContain("Nested include")
36
37
  expect(markup).toContain("IT WORKS!")
37
38
  })
39
+ it("Should recognise default Drupal functions", () => {
40
+ const markup = drupalFunctions()
41
+ expect(markup).toMatchSnapshot()
42
+ expect(markup).toContain("Functions work")
43
+ })
38
44
  })
package/vite.config.js CHANGED
@@ -11,6 +11,10 @@ export default defineConfig({
11
11
  error: resolve(__dirname, "tests/fixtures/error.twig"),
12
12
  menu: resolve(__dirname, "tests/fixtures/menu.twig"),
13
13
  errorInclude: resolve(__dirname, "tests/fixtures/error-include.twig"),
14
+ drupalFunctions: resolve(
15
+ __dirname,
16
+ "tests/fixtures/drupal-functions.twig"
17
+ ),
14
18
  },
15
19
  name: "vite-plugin-twig-drupal",
16
20
  fileName: (_, entry) => `${entry}.js`,