eleventy-plugin-vento 2.6.0 → 3.0.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +235 -0
  2. package/LICENSE +1 -1
  3. package/package.json +61 -56
  4. package/readme.md +98 -76
  5. package/src/engine.js +84 -0
  6. package/src/index.js +130 -0
  7. package/src/modules/create-vento-tag.js +56 -0
  8. package/src/modules/ignore-tag.js +15 -0
  9. package/src/modules/utils.js +25 -0
  10. package/.editorconfig +0 -16
  11. package/.github/actions/setup/action.yml +0 -25
  12. package/.github/renovate.json +0 -13
  13. package/.github/workflows/ci.yml +0 -15
  14. package/.github/workflows/release.yml +0 -33
  15. package/.node-version +0 -1
  16. package/.vscode/settings.json +0 -4
  17. package/.vscode/tests.code-snippets +0 -16
  18. package/VentoPlugin.js +0 -140
  19. package/eslint.config.js +0 -67
  20. package/jsconfig.json +0 -11
  21. package/lib/ssr.js +0 -23
  22. package/release.config.js +0 -31
  23. package/tests/autotrim/__snapshots__/autotrim-all.html +0 -53
  24. package/tests/autotrim/__snapshots__/autotrim-single.html +0 -75
  25. package/tests/autotrim/autotrim.test.js +0 -17
  26. package/tests/autotrim/build/autotrim-all.html +0 -53
  27. package/tests/autotrim/build/autotrim-single.html +0 -75
  28. package/tests/autotrim/index.vto +0 -23
  29. package/tests/basic/__snapshots__/template-basic.html +0 -4
  30. package/tests/basic/basic.test.js +0 -9
  31. package/tests/basic/index.vto +0 -7
  32. package/tests/computed-data/__snapshots__/from-local-key.html +0 -4
  33. package/tests/computed-data/computed-data.test.js +0 -9
  34. package/tests/computed-data/from-local-key.vto +0 -9
  35. package/tests/engine-overrides/__snapshots__/as-html-engine.html +0 -4
  36. package/tests/engine-overrides/__snapshots__/as-md-engine.html +0 -2
  37. package/tests/engine-overrides/as-html-engine.html +0 -7
  38. package/tests/engine-overrides/as-md-engine.md +0 -7
  39. package/tests/engine-overrides/eleventy.config.js +0 -4
  40. package/tests/engine-overrides/engine-overrides.test.js +0 -14
  41. package/tests/filters/__snapshots__/filters-arguments.html +0 -1
  42. package/tests/filters/__snapshots__/filters-basic.html +0 -2
  43. package/tests/filters/basic.vto +0 -5
  44. package/tests/filters/eleventy.config.js +0 -13
  45. package/tests/filters/filters.test.js +0 -19
  46. package/tests/filters/with-arguments.vto +0 -1
  47. package/tests/filters/with-this.vto +0 -1
  48. package/tests/get-instance.js +0 -38
  49. package/tests/includes/__snapshots__/includes-basic.html +0 -8
  50. package/tests/includes/__snapshots__/includes-data.html +0 -8
  51. package/tests/includes/_includes/partial.vto +0 -4
  52. package/tests/includes/basic.vto +0 -7
  53. package/tests/includes/includes.test.js +0 -14
  54. package/tests/includes/with-data.vto +0 -7
  55. package/tests/layouts/__snapshots__/example-layout-1.html +0 -27
  56. package/tests/layouts/__snapshots__/example-layout-2.html +0 -24
  57. package/tests/layouts/_includes/layout1.vto +0 -20
  58. package/tests/layouts/_includes/layout2.vto +0 -17
  59. package/tests/layouts/layouts.test.js +0 -14
  60. package/tests/layouts/page1.vto +0 -11
  61. package/tests/layouts/page2.vto +0 -11
  62. package/tests/permalinks/__snapshots__/permalink-nested.html +0 -15
  63. package/tests/permalinks/__snapshots__/permalink-root.html +0 -15
  64. package/tests/permalinks/_includes/layout.vto +0 -13
  65. package/tests/permalinks/at-nested.vto +0 -7
  66. package/tests/permalinks/at-root.vto +0 -7
  67. package/tests/permalinks/dynamic/dynamic-permalink.vto +0 -6
  68. package/tests/permalinks/dynamic/dynamic.11tydata.json +0 -3
  69. package/tests/permalinks/dynamic-js/dynamic-js.11tydata.js +0 -5
  70. package/tests/permalinks/dynamic-js/dynamic-permalink-js.vto +0 -6
  71. package/tests/permalinks/permalinks.test.js +0 -25
  72. package/tests/permalinks/skip.vto +0 -7
  73. package/tests/shortcodes/__snapshots__/shortcode-with-arguments.html +0 -2
  74. package/tests/shortcodes/basic.vto +0 -1
  75. package/tests/shortcodes/eleventy.config.js +0 -4
  76. package/tests/shortcodes/shortcodes.test.js +0 -14
  77. package/tests/shortcodes/with-arguments.vto +0 -2
  78. package/tests/ssr/__snapshots__/ssr-data.html +0 -1
  79. package/tests/ssr/__snapshots__/ssr-echo.html +0 -7
  80. package/tests/ssr/__snapshots__/ssr-exec.html +0 -1
  81. package/tests/ssr/__snapshots__/ssr-for.html +0 -3
  82. package/tests/ssr/__snapshots__/ssr-if.html +0 -5
  83. package/tests/ssr/data.vto +0 -1
  84. package/tests/ssr/echo.vto +0 -7
  85. package/tests/ssr/exec.vto +0 -1
  86. package/tests/ssr/for.vto +0 -3
  87. package/tests/ssr/if.vto +0 -5
  88. package/tests/ssr/ssr.test.js +0 -29
package/CHANGELOG.md ADDED
@@ -0,0 +1,235 @@
1
+ # eleventy-plugin-vento
2
+
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9f5a90f: Various Refactors - These changes shouldn't have any observable effect on your templates or usage.
8
+
9
+ - Replaced `class` based approach for a closure implementation instead. Since there was only 1 Vento `env` object ever instanced in this plugin, steering away from using `class` removes some complexity and overhead.
10
+
11
+ - `DATA_KEYS` (used internally) moved into utils file alongside other utilities (like compatibility checks) and renamed to `CONTEXT_DATA_KEYS`.
12
+
13
+ - Moved internal Vento/11ty data from env.\_11ty => env.utils.\_11ty. Previous versions mutated the Vento `env` object by adding an `_11ty` key with everything that needed accessing from within a template compile (shortcodes, filters, etc.). This was moved this back to `env.utils._11ty` since it's probably a more appropriate place to store these functions.
14
+
15
+ ## 3.0.0
16
+
17
+ ### Major Changes
18
+
19
+ - 668700c: Enforce new minimum version — [Eleventy v3.0.0-alpha.15](https://github.com/11ty/eleventy/releases/tag/v3.0.0-alpha.15) or later is now **required** for this plugin to function.
20
+
21
+ Although this goes against the _backwards compatibility_ ethos of Eleventy, the addition of the `getShortcodes()` and `getPairedShortcodes()` functions that were added in `alpha.15` are now utilized in this plugin to bring even more goodness to your templates.
22
+
23
+ Thanks [@zachleat](https://github.com/zachleat) for making this possible!
24
+
25
+ - 9d8eb8a: Adds complete support for Eleventy shortcodes and filters within Vento. Shortcodes are now loaded by default as Vento tags and will no longer be exposed as functions in your page data.
26
+
27
+ The implementation of single shortcodes remains largely similar, just replace function-like calls with Vento tags.
28
+
29
+ ```diff
30
+ - {{ nametag('Noel', 'Forte') }}
31
+ + {{ nametag 'Noel', 'Forte' }}
32
+ ```
33
+
34
+ Of course, the big news is that **paired** shortcodes are now officially supported by this plugin!! Prior to this release, paired shortcodes were exposed just like regular shortcodes, but were plain JS functions. With this release you can now use paired shortcodes just like any other tag.
35
+
36
+ ```hbs
37
+ <!-- Before: everything is jammed into the function call :( -->
38
+ {{ blockquote("<p>Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.</p>\n<p>It is a way I have of driving off the spleen and regulating the circulation.</p>", "Herman Melville", "1851") }}
39
+
40
+ <!-- After: opening and closing tags with arguments separated :) -->
41
+ {{ blockquote 'Herman Melville', '1851' }}
42
+ <p>Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.</p>
43
+ <p>It is a way I have of driving off the spleen and regulating the circulation.</p>
44
+ {{ /blockquote }}
45
+ ```
46
+
47
+ Because these changes removed direct dependence on Eleventy JavaScript functions, the `addHelpers` option has been replaced with 3 new options: `shortcodes`, `pairedShortcodes` and `filters`. **All of them are enabled by default** but can be disabled in your plugin config like so.
48
+
49
+ ```diff
50
+ eleventyConfig.addPlugin(VentoPlugin, {
51
+ - addHelpers: false,
52
+ + shortcodes: false,
53
+ + pairedShortcodes: false,
54
+ + filters: false,
55
+ });
56
+ ```
57
+
58
+ - 516cd2f: Modifications to `auto_trim` functionality
59
+
60
+ Starting with this release the way the `auto_trim` plugin is implemented is a bit different.
61
+
62
+ The plugin option `trimTags` is now `autotrim`. Be sure to update your plugin options object accordingly:
63
+
64
+ ```diff
65
+ eleventyConfig.addPlugin(VentoPlugin, {
66
+ - trimTags: true
67
+ + autotrim: true
68
+ });
69
+ ```
70
+
71
+ Additionally, the eleventy plugin no longer re-exports `defaultTags` from `ventojs`. Be sure to remove any imports from your config:
72
+
73
+ ```diff
74
+ - import { ventoDefaultTrimTags } from 'eleventy-plugin-vento';
75
+ ```
76
+
77
+ To extend the default tags list, this plugin now provides a 2 placeholder values for your array of tags, `@vento` and `@11ty`. When the plugin executes, `@vento` will be expanded to the default vento tags list, and `@11ty` will be expanded to the names of all paired shortcodes.
78
+
79
+ ```js
80
+ eleventyConfig.addPlugin(VentoPlugin, {
81
+ autotrim: ['@vento', '@11ty', 'tag1', 'tag2'],
82
+ });
83
+ ```
84
+
85
+ Setting `autotrim: true` is the same as `autotrim: ['@vento', '@11ty']`.
86
+
87
+ ### Minor Changes
88
+
89
+ - ff75e09: Add option to explicitly enable tag ignore syntax.
90
+
91
+ Prior to this release this feature was referred to as the "SSR" or "hybrid-rendering" syntax. It's purpose was to skip over processing a tag like Vento's built-in `{{ echo }}` tag, but with a much shorter syntax: `{{! ... }}`. Any code following a `!` in your markup is wrapped in `{{ }}` and output as-is.
92
+
93
+ ```hbs
94
+ {{!> console.log('Hello world'); }} <!-- tag remains in output -->
95
+ ```
96
+
97
+ In this release, this behavior is now explicitly opt-in. To enable it, include `ignoreTag: true` in the plugin options:
98
+
99
+ ```js
100
+ eleventyConfig.addPlugin(VentoPlugin, {
101
+ ignoreTag: true,
102
+ });
103
+ ```
104
+
105
+ - b9e8232: Update ventojs to 1.12.10
106
+
107
+ ## 2.6.0
108
+
109
+ ### New Features
110
+
111
+ - fine-tune caching ([5b5035a](https://github.com/noelforte/eleventy-plugin-vento/commit/5b5035aedd89f57cb7d06e23d6fdef26fde55644))
112
+
113
+ ### Bug Fixes
114
+
115
+ - remove `inputPath` from cache if `rawInput` doesn't match `inputContent` ([529d0b5](https://github.com/noelforte/eleventy-plugin-vento/commit/529d0b56fcc9175c698c7f243db51f79088d0849))
116
+
117
+ ## 2.5.0
118
+
119
+ ### Dependency Updates
120
+
121
+ - update dependency ventojs to v0.12.9 ([2f664f3](https://github.com/noelforte/eleventy-plugin-vento/commit/2f664f39fac591b5daf9154b2c639542a65d9aad))
122
+
123
+ ## 2.4.0
124
+
125
+ ### Dependency Updates
126
+
127
+ - update dependency ventojs to v0.12.8 ([f08ed15](https://github.com/noelforte/eleventy-plugin-vento/commit/f08ed15e42b67a044ac171156d6bf768e6bed7e5))
128
+
129
+ ## 2.3.0
130
+
131
+ ### New Features
132
+
133
+ - `!` tag ([49bdaf8](https://github.com/noelforte/eleventy-plugin-vento/commit/49bdaf8a0ac65a3bab6d7de5abcba7c20ee3fcaf))
134
+
135
+ ## 2.2.0
136
+
137
+ ### New Features
138
+
139
+ - update ventojs to 0.12.7 ([f4735ba](https://github.com/noelforte/eleventy-plugin-vento/commit/f4735bacdeae3605cdc0ba4e8b9bc9ec2f84d30d))
140
+
141
+ ### Bug Fixes
142
+
143
+ - remove input path when compiling permalinks, it messes up the cache ([7dcae1a](https://github.com/noelforte/eleventy-plugin-vento/commit/7dcae1a7eb4b8611d5df982e42f6abe9b69f2871))
144
+
145
+ ## 2.1.0
146
+
147
+ ### New Features
148
+
149
+ - only bind `page` and `eleventy` to helper functions to align with core functionality ([a2e023c](https://github.com/noelforte/eleventy-plugin-vento/commit/a2e023cab00666046f99dc99857a77514be4622d))
150
+
151
+ ### Bug Fixes
152
+
153
+ - `trimTags` now applies default tags as expected when set to `true` ([9b25279](https://github.com/noelforte/eleventy-plugin-vento/commit/9b252796f3bb31963a5435bc0cc1e238392c74e1))
154
+ - **filters:** use env.filters instead of filters so filters load correctly ([145029e](https://github.com/noelforte/eleventy-plugin-vento/commit/145029efc3b421b04189b665740825b4f32eff2c))
155
+ - use `eleventyConfig.directories` to resolve `includes` directory ([3e1a88a](https://github.com/noelforte/eleventy-plugin-vento/commit/3e1a88a0e651033e7bba35431bcb0ce8d16a9cd7))
156
+
157
+ ## 2.0.0
158
+
159
+ ### ⚠ BREAKING CHANGES
160
+
161
+ - rework filters to pull from eleventy definitions rather than defining a separate object
162
+
163
+ ### New Features
164
+
165
+ - compile permalinks with vento using instance configuration ([170dc4d](https://github.com/noelforte/eleventy-plugin-vento/commit/170dc4d5a45f8a3dd25f57b99cfea9db8196a820))
166
+ - rework filters to pull from eleventy definitions rather than defining a separate object ([a98355a](https://github.com/noelforte/eleventy-plugin-vento/commit/a98355a8a0fcdc8f63ba507997f1a5e93b0b266a))
167
+ - wire up internal autoTrim plugin as trimTags option ([7756c06](https://github.com/noelforte/eleventy-plugin-vento/commit/7756c06f02ccbab5a689909e66733d09d1ab2c19))
168
+
169
+ ### Bug Fixes
170
+
171
+ - add exports to package.json ([b07c53b](https://github.com/noelforte/eleventy-plugin-vento/commit/b07c53bc6a804608ad7a395a1f1e8d540ebaded8))
172
+ - exports from VentoPlugin and imports/syntax on eleventy.config.js ([f719c99](https://github.com/noelforte/eleventy-plugin-vento/commit/f719c990580241c343e7e2c0753926a6086d4e32))
173
+ - only compile linkContents if it's a string ([ddca393](https://github.com/noelforte/eleventy-plugin-vento/commit/ddca393d837c175e8f3707cea9e1eb863bd10ec3))
174
+ - set up filters beforehand so they're accessible in permalinks ([58a4992](https://github.com/noelforte/eleventy-plugin-vento/commit/58a4992ea56778d8da28869c3ae06a499243cf90))
175
+
176
+ ## 2.0.0-beta.5
177
+
178
+ ### Bug Fixes
179
+
180
+ - compile permalinks properly so permalinks starting with `/` don't default to their `permalink` values ([fc69db5](https://github.com/noelforte/eleventy-plugin-vento/commit/fc69db5b60acb0ba1a0aa5247ad71ace6610c3b7))
181
+ - move cache clearing to compile step, rather than eleventy.before. ([44a424c](https://github.com/noelforte/eleventy-plugin-vento/commit/44a424cf0b10b641f67aadba0670f112e6e0d06c))
182
+
183
+ ## 2.0.0-beta.4
184
+
185
+ ### Bug Fixes
186
+
187
+ - only compile linkContents if it's a string ([ddca393](https://github.com/noelforte/eleventy-plugin-vento/commit/ddca393d837c175e8f3707cea9e1eb863bd10ec3))
188
+
189
+ ## 2.0.0-beta.3
190
+
191
+ ### Bug Fixes
192
+
193
+ - set up filters beforehand so they're accessible in permalinks ([58a4992](https://github.com/noelforte/eleventy-plugin-vento/commit/58a4992ea56778d8da28869c3ae06a499243cf90))
194
+
195
+ ## 2.0.0-beta.2
196
+
197
+ ### New Features
198
+
199
+ - compile permalinks with vento using instance configuration ([170dc4d](https://github.com/noelforte/eleventy-plugin-vento/commit/170dc4d5a45f8a3dd25f57b99cfea9db8196a820))
200
+
201
+ ## 1.1.3
202
+
203
+ ### Bug Fixes
204
+
205
+ - move cache clearing to compile step, rather than eleventy.before. ([44a424c](https://github.com/noelforte/eleventy-plugin-vento/commit/44a424cf0b10b641f67aadba0670f112e6e0d06c))
206
+
207
+ ## 2.0.0-beta.1
208
+
209
+ ### ⚠ BREAKING CHANGES
210
+
211
+ The 2.0.0 release of this plugin does away with a separate filters object and defers all filter handling to Eleventy. This way any filters you already have in your Eleventy code don't have to be defined twice. If this project had started with a 0.x.x version then I wouldn't be pushing 2.0 out this fast, but I'm new to releasing npm packages so we started on 1.0. Thanks for your patience as I learn the ins and outs of SemVer!!
212
+
213
+ ### New Features
214
+
215
+ - rework filters to pull from eleventy definitions rather than defining a separate object ([a98355a](https://github.com/noelforte/eleventy-plugin-vento/commit/a98355a8a0fcdc8f63ba507997f1a5e93b0b266a))
216
+ - wire up internal autoTrim plugin as trimTags option ([7756c06](https://github.com/noelforte/eleventy-plugin-vento/commit/7756c06f02ccbab5a689909e66733d09d1ab2c19))
217
+
218
+ ### Bug Fixes
219
+
220
+ - add exports to package.json ([b07c53b](https://github.com/noelforte/eleventy-plugin-vento/commit/b07c53bc6a804608ad7a395a1f1e8d540ebaded8))
221
+ - exports from VentoPlugin and imports/syntax on eleventy.config.js ([f719c99](https://github.com/noelforte/eleventy-plugin-vento/commit/f719c990580241c343e7e2c0753926a6086d4e32))
222
+
223
+ ## 1.1.2
224
+
225
+ ### Bug Fixes
226
+
227
+ - compile permalinks properly so permalinks starting with `/` don't default to their `permalink` values ([fc69db5](https://github.com/noelforte/eleventy-plugin-vento/commit/fc69db5b60acb0ba1a0aa5247ad71ace6610c3b7))
228
+
229
+ ## v1.1.1
230
+
231
+ Add example to docs showing examples for loading plugins.
232
+
233
+ ## v1.1.0
234
+
235
+ - Add ability to load Vento plugins.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Noel Forte
3
+ Copyright (c) Noel Forte <noel@forte.is> (https://forte.is/)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,57 +1,62 @@
1
1
  {
2
- "name": "eleventy-plugin-vento",
3
- "version": "2.6.0",
4
- "description": "Adds support for the Vento templating language to Eleventy.",
5
- "type": "module",
6
- "packageManager": "pnpm@9.5.0",
7
- "engines": {
8
- "node": ">=16"
9
- },
10
- "scripts": {
11
- "test": "vitest",
12
- "lint": "eslint **/*.js --config ./eslint.config.js"
13
- },
14
- "main": "./VentoPlugin.js",
15
- "imports": {
16
- "#lib/*": "./lib/*",
17
- "#test-instance": "./tests/get-instance.js"
18
- },
19
- "exports": {
20
- ".": "./VentoPlugin.js"
21
- },
22
- "repository": "git@github.com:noelforte/eleventy-plugin-vento.git",
23
- "bugs": {
24
- "url": "https://github.com/noelforte/eleventy-plugin-vento/issues"
25
- },
26
- "keywords": [
27
- "eleventy",
28
- "eleventy-plugin",
29
- "ventojs",
30
- "templating"
31
- ],
32
- "author": {
33
- "name": "Noel Forte",
34
- "email": "noel@forte.is",
35
- "url": "https://forte.is/"
36
- },
37
- "license": "MIT",
38
- "dependencies": {
39
- "ventojs": "0.12.9"
40
- },
41
- "devDependencies": {
42
- "@11ty/eleventy": "3.0.0-alpha.14",
43
- "conventional-changelog-conventionalcommits": "8.0.0",
44
- "eslint": "9.6.0",
45
- "eslint-config-flat-gitignore": "0.1.7",
46
- "eslint-config-prettier": "9.1.0",
47
- "globals": "15.8.0",
48
- "semantic-release": "24.0.0",
49
- "vitest": "2.0.2"
50
- },
51
- "prettier": {
52
- "bracketSameLine": true,
53
- "singleQuote": true,
54
- "semi": true,
55
- "trailingComma": "es5"
56
- }
57
- }
2
+ "name": "eleventy-plugin-vento",
3
+ "version": "3.0.1",
4
+ "description": "Adds support for the Vento templating language to Eleventy.",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=16"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "import": "./src/index.js"
12
+ }
13
+ },
14
+ "repository": "git@github.com:noelforte/eleventy-plugin-vento.git",
15
+ "bugs": {
16
+ "url": "https://github.com/noelforte/eleventy-plugin-vento/issues"
17
+ },
18
+ "keywords": [
19
+ "eleventy",
20
+ "eleventy-plugin",
21
+ "ventojs",
22
+ "templating"
23
+ ],
24
+ "author": {
25
+ "name": "Noel Forte",
26
+ "email": "noel@forte.is",
27
+ "url": "https://forte.is/"
28
+ },
29
+ "license": "MIT",
30
+ "files": [
31
+ "src/*",
32
+ "CHANGELOG.md"
33
+ ],
34
+ "dependencies": {
35
+ "ventojs": "1.12.10"
36
+ },
37
+ "devDependencies": {
38
+ "@11ty/eleventy": "3.0.0-beta.1",
39
+ "@changesets/cli": "2.27.8",
40
+ "eslint": "9.11.1",
41
+ "eslint-config-flat-gitignore": "0.3.0",
42
+ "eslint-config-prettier": "9.1.0",
43
+ "eslint-plugin-unicorn": "55.0.0",
44
+ "globals": "15.9.0",
45
+ "vitest": "2.1.1",
46
+ "zx": "8.1.8"
47
+ },
48
+ "prettier": {
49
+ "bracketSameLine": true,
50
+ "singleQuote": true,
51
+ "semi": true,
52
+ "trailingComma": "es5"
53
+ },
54
+ "scripts": {
55
+ "test": "vitest --run",
56
+ "lint": "eslint '**/*.js'",
57
+ "ci:version": "npm audit signatures && changeset version && pnpm install --no-frozen-lockfile",
58
+ "ci:publish": "changeset publish",
59
+ "ci:generate-changesets": "node ./scripts/generate-changesets.js",
60
+ "format": "pnpm dlx prettier --config ./package.json --write ."
61
+ }
62
+ }
package/readme.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # eleventy-plugin-vento 🌬️🎈🐀
2
2
 
3
+ <img src="https://img.shields.io/badge/Eleventy-v3_&amp;_later_-333?style=flat-square&logo=eleventy&logoColor=fff&labelColor=333&color=111" alt="Eleventy v3 and later">
3
4
  <a href="https://github.com/noelforte/eleventy-plugin-vento/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/noelforte/eleventy-plugin-vento/ci.yml?branch=main&style=flat-square&logo=github&logoColor=fff&label=Tests&labelColor=333" alt="Github Actions Status"></a>
4
5
  <a href="https://npmjs.com/package/eleventy-plugin-vento"><img src="https://img.shields.io/npm/v/eleventy-plugin-vento?style=flat-square&logo=npm&logoColor=fff&labelColor=333" alt="eleventy-plugin-vento on npm"></a>
5
- <a href="https://github.com/semantic-release/semantic-release"><img src="https://img.shields.io/badge/semantic--release-Conventional_Commits-fa6673?style=flat-square&logo=semanticrelease&logoColor=fff&labelColor=333" alt="semantic-release"></a>
6
+ <a href="https://github.com/changesets/changesets/"><img src="https://img.shields.io/badge/🦋_Changesets-333?style=flat-square" alt="changesets on GitHub"></a>
6
7
 
7
8
  An [Eleventy](https://11ty.dev/) plugin that adds support for [Vento](https://vento.js.org/) templates.
8
9
 
@@ -12,10 +13,10 @@ An [Eleventy](https://11ty.dev/) plugin that adds support for [Vento](https://ve
12
13
  [Usage](#usage)<br>
13
14
  [Plugin Options](#plugin-options)<br>
14
15
  [Filters](#filters)<br>
16
+ [Shortcodes (Single & Paired)](#shortcodes-single--paired)<br>
15
17
  [Vento Plugins](#vento-plugins)<br>
16
18
  [Auto-Trimming Tags](#auto-trimming-tags)<br>
17
- [JavaScript Helpers](#javascript-helpers)<br>
18
- [Hybrid Rendering](#hybrid-rendering)<br>
19
+ [Ignoring Tags](#ignoring-tags)<br>
19
20
 
20
21
  ## Installing
21
22
 
@@ -25,9 +26,9 @@ npm install eleventy-plugin-vento
25
26
 
26
27
  ## Usage
27
28
 
28
- This plugin is ESM only and cannot be required from CommonJS. As such, it's best used with Eleventy v3.0.0.
29
+ This plugin is ESM only and cannot be required from CommonJS.
29
30
 
30
- If you're using CommonJS and loading it asynchronously (ie `await import`), you will need at minimum Eleventy v1.0.0 which added support for [Custom Templates](https://www.11ty.dev/docs/languages/custom/).
31
+ If you're using CommonJS and loading it asynchronously (ie `await import`), you will need at **minimum** Eleventy v3.0.0-alpha.15 which provides internal methods this plugin uses to get Eleventy stuff from the config API.
31
32
 
32
33
  In your Eleventy config:
33
34
 
@@ -48,21 +49,25 @@ import { VentoPlugin } from 'eleventy-plugin-vento';
48
49
 
49
50
  export default function (eleventyConfig) {
50
51
  eleventyConfig.addPlugin(VentoPlugin, {
51
- // An array of Vento plugins to load
52
+ // An array of Vento plugins to use when compiling
52
53
  plugins: [],
53
54
 
54
- // Define whether Javascript Functions should be added
55
- // to page data. See below for usage notes on this.
56
- addHelpers: true,
55
+ // Enable/disable Eleventy Shortcodes, Paired Shortcodes,
56
+ // and Filters in .vto templates
57
+ shortcodes: true,
58
+ pairedShortcodes: true,
59
+ filters: true,
57
60
 
58
61
  // Define tags that should be trimmed, or set to true
59
62
  // to trim the default tags (see section on Auto-trimming)
60
- trimTags: [],
63
+ autotrim: false,
64
+
65
+ // Enable/disable ignore tag syntax (see section on ignoring tags)
66
+ ignoreTag: false,
61
67
 
62
68
  // A Vento configuration object
63
69
  ventoOptions: {
64
- includes: '...', // defaults to the Eleventy 'includes' directory
65
- autoescape: false,
70
+ includes: eleventyConfig.directories.includes,
66
71
  },
67
72
  });
68
73
  }
@@ -72,14 +77,75 @@ View the [full list of options](https://vento.js.org/configuration/#options/) to
72
77
 
73
78
  ## Filters
74
79
 
75
- Filters that are added using Eleventy's `.addFilter()` or `.addAsyncFilter()` methods will be automatically loaded into Vento. Since Vento filters and Eleventy filters follow the same syntax for filters (content as first argument), the implementation is 1:1.
80
+ > [!NOTE]
81
+ > Remember, Vento can pipe any JS data type to any built-in global as the first-argument or any `.prototype` method in addition to declared filters. For instance to print the `eleventy` variable as JSON you could use the following snippet:
82
+ >
83
+ > ```nunjucks
84
+ > {{ eleventy |> JSON.stringify }}
85
+ > ```
86
+ >
87
+ > In these cases, Eleventy filters may not be needed depending on your usage.
88
+
89
+ Filters that are added via Eleventy's `.addFilter()` or `.addAsyncFilter()` methods will be automatically loaded into Vento. Since Vento filters and Eleventy filters follow the same syntax for filters (content as first argument), the implementation is 1:1.
90
+
91
+ If you'd prefer to set filters yourself (via a plugin or other method) or prevent Eleventy from loading filters into Vento, set `filters: false` in the plugin options.
92
+
93
+ ### Relevant documentation
94
+
95
+ Vento: See [Filters](https://vento.js.org/configuration/#filters) and [Pipes](https://vento.js.org/syntax/pipes/)
96
+
97
+ Eleventy: See [Filters](https://www.11ty.dev/docs/filters/)
98
+
99
+ ## Shortcodes (Single & Paired)
76
100
 
77
- [More information about Vento filters](https://vento.js.org/configuration/#filters)
101
+ > [!NOTE]
102
+ > Remember, Vento can print any return value from a Javascript expression, as well as [run arbitrary JavaScript](https://vento.js.org/syntax/javascript/) in templates through its `{{> ...}}` operator. In these cases, shortcodes may not be needed depending on your usage.
78
103
 
79
- [More information about Eleventy filters](https://www.11ty.dev/docs/filters/)
104
+ Single and Paired Shortcodes added via Eleventy's `.addShortcode()`, `addAsyncShortcode()`, `addPairedShortcode()` or `.addAsyncPairedShortcode()` will be automatically loaded into Vento.
105
+
106
+ When using shortcodes in your templates, write them like any other Vento tag:
107
+
108
+ ```nunjucks
109
+ {{ myShortcode }}
110
+ ```
111
+
112
+ To pass arguments, add a space and your arguments, comma-separated. Arguments are interpreted as JavaScript so type-safety should be considered (quote strings, use booleans if your shortcode expects them, etc.)
113
+
114
+ ```nunjucks
115
+ {{ myShortcode 'arg1', 'arg2' }}
116
+ {{ myBooleanShortcode false, false, true }}
117
+ {{ myNumberShortcode 10, 20, 0 }}
118
+ {{ myObjectShortcode { key1: 'val1', key2: 'val2' } }}
119
+ ```
120
+
121
+ For paired shortcodes, the syntax is the same, just add a closing tag. Paired shortcodes also accept arguments and can re-process nested Vento tags (including other shortcodes).
122
+
123
+ ```nunjucks
124
+ {{ codeBlock 'css' }} <!-- takes arguments too -->
125
+ a {
126
+ color: red;
127
+ }
128
+ {{ /codeBlock }}
129
+
130
+ {{ blockQuote }}
131
+ To be or not to be, that is the question.
132
+ {{ attribute 'William Shakespeare' }} <!-- you can use vento syntax here too -->
133
+ {{ /blockQuote }}
134
+ ```
135
+
136
+ If you'd prefer to set shortcodes yourself (via a plugin or other method) or prevent Eleventy from loading shortcodes into Vento, set `shortcodes: false` and/or `pairedShortcodes: false` in the plugin options.
137
+
138
+ > [!CAUTION]
139
+ > While it's straightforward to load filters via a Vento plugin that appends filters to the filters object as `env.filters.[filter_name]()`, creating custom tags in Vento is more involved. It's highly advised to keep these two options enabled unless you know what you're doing.
140
+
141
+ ### Relevant Documentation
142
+
143
+ Eleventy: See [Shortcodes](https://www.11ty.dev/docs/shortcodes/) and the sub-section on [Paired Shortcodes](https://www.11ty.dev/docs/shortcodes/#paired-shortcodes).
80
144
 
81
145
  ## Vento Plugins
82
146
 
147
+ _Note: The `auto_trim` plugin that ships with Vento has a specific implementation in the scope of this plugin. See [Auto-Trimming Tags](#auto-trimming-tags) for more details._
148
+
83
149
  If you'd like to extend the Vento library with any plugins, include them in an array passed to the `plugins` option.
84
150
 
85
151
  ```js
@@ -91,7 +157,7 @@ function myCustomPlugin() {
91
157
 
92
158
  export default function (eleventyConfig) {
93
159
  eleventyConfig.addPlugin(VentoPlugin, {
94
- plugins: [myCustomPlugin()],
160
+ plugins: [myCustomPlugin],
95
161
  });
96
162
  }
97
163
  ```
@@ -100,94 +166,50 @@ export default function (eleventyConfig) {
100
166
 
101
167
  One exception to Vento plugins is the `autoTrim` plugin which is bundled with Vento, and by extension, this plugin. This plugin provides a convenient way to control whitespace in the output by collapsing spaces left behind when Vento's tags are removed.
102
168
 
103
- To trim the default tags, set the `trimTags` plugin option to `true`.
169
+ To trim space around the default tags and all Eleventy paired shortcodes, set the `autotrim` plugin option to `true`.
104
170
 
105
171
  ```js
106
172
  eleventyConfig.addPlugin(VentoPlugin, {
107
- trimTags: true,
173
+ autotrim: true,
108
174
  });
109
175
  ```
110
176
 
111
- The default set of tags that are trimmed are defined by Vento and are listed in the [usage notes](https://vento.js.org/plugins/auto-trim/#usage) for the auto trim plugin. To set your own tags, set `trimTags` to an array instead.
177
+ The default set of tags that are trimmed are [defined by Vento itself](https://github.com/ventojs/vento/blob/8c767d45441c2d5a90b6b2b4e33bec56018807d3/plugins/auto_trim.ts#L4-L20). To set your own list of tags, set `autotrim` to an array of tags:
112
178
 
113
179
  ```js
114
180
  eleventyConfig.addPlugin(VentoPlugin, {
115
- trimTags: ['set', 'if', 'for'],
181
+ autotrim: ['set', 'if', 'for'],
116
182
  });
117
183
  ```
118
184
 
119
- If instead, you'd like to extend instead of replace the default tag list, `eleventy-plugin-vento` reexports the `defaultTags` array used by as `ventoDefaultTrimTags`, which can be used like so:
185
+ If instead, you'd like to extend instead of replace the default tag list, add the value `@vento` and/or `@11ty`. These placeholders will expand to the Vento default tags and Eleventy paired shortcode tags when the plugin executes.
120
186
 
121
187
  ```js
122
- import { VentoPlugin, ventoDefaultTrimTags } from 'eleventy-plugin-vento';
188
+ import { VentoPlugin } from 'eleventy-plugin-vento';
123
189
 
124
190
  eleventyConfig.addPlugin(VentoPlugin, {
125
- trimTags: [...ventoDefaultTrimTags, 'tag'],
191
+ autotrim: {
192
+ tags: ['@vento', '@11ty', 'tag'],
193
+ },
126
194
  });
127
195
  ```
128
196
 
129
- For more information on the auto-trim plugin, consult the [plugin documentation](https://vento.js.org/plugins/auto-trim/).
197
+ ### Relevant documentation
130
198
 
131
- ## JavaScript Helpers
199
+ Vento: See [Auto Trim Plugin](https://vento.js.org/plugins/auto-trim/).
132
200
 
133
- Vento can [run arbitrary JavaScript](https://vento.js.org/syntax/javascript/) in templates through its `{{> ...}}` operator, which evaluates at the time the template is run. However, you may want to use Eleventy Shortcodes and Filters in your templates as well.
201
+ ## Ignoring Tags
134
202
 
135
- By setting `addHelpers` in the plugin options (defaults to `true`), all JavaScript functions (which includes any Universal Shortcodes) are exposed as functions in page data. This feature functions very similarly to WebC's ["helper functions"](https://www.11ty.dev/docs/languages/javascript/#javascript-template-functions) feature.
136
-
137
- As an example:
138
-
139
- ```js
140
- export default function (eleventyConfig) {
141
- // via Universal Filter...
142
- eleventyConfig.addFilter('italicize', (content) => `<em>${content}</em>`);
143
-
144
- // ...or via Universal Shortcode
145
- eleventyConfig.addShortcode('greeting', (name) => `My name is ${name}`);
146
-
147
- // ...or via JavaScript Template Function
148
- eleventyConfig.addJavaScriptFunction('possumPosse', () => 'Release the possums!!!');
149
- }
150
- ```
151
-
152
- ```hbs
153
- <p>This is something {{ italicize('really') }} important.</p>
154
- <p>{{ possumPosse() }}</p>
155
-
156
- <!-- renders as: -->
157
-
158
- <p>This is something <em>really</em> important.</p>
159
- <p>Release the possums!!!</p>
160
-
161
- ```
162
-
163
- Alternatively, if you'd rather keep functions namespaced in your page data, pass a string to `addHelpers`. Your functions will be namespaced under this property name in page data.
164
-
165
- ```js
166
- addPlugin(VentoPlugin, { addHelpers: 'functions' });
167
- ```
168
-
169
- ```nunjucks
170
- <!-- With the above, this: -->
171
- <p>This is something {{ italicize('really') }} important.</p>
172
- <p>{{ possumPosse() }}</p>
173
-
174
- <!-- should be written as: -->
175
- <p>This is something {{ functions.italicize('really') }} important.</p>
176
- <p>{{ functions.possumPosse() }}</p>
177
- ```
203
+ Exclusive to this plugin is the ability to skip processing a vento tag entirely and instead preserve the tag in the markup. This could be useful if you're doing some hybrid rendering and would like to defer certain tags from being processed until load time, so they can be rendered on the server.
178
204
 
179
- Finally, if you'd like to disable populating helper functions at all, set `addHelpers` to false:
205
+ This feature is enabled through use of the `enableIgnoreTag` plugin option.
180
206
 
181
207
  ```js
182
208
  eleventyConfig.addPlugin(VentoPlugin, {
183
- addHelpers: false,
209
+ enableIgnoreTag: true,
184
210
  });
185
211
  ```
186
212
 
187
- ## Hybrid Rendering
188
-
189
- Exclusive to this plugin is the ability to skip processing a vento tag entirely and instead preserve the tag in the markup. This could be useful if you're doing some hybrid rendering and would like to defer certain tags from being processed until load time, so they can be rendered on the server.
190
-
191
213
  To skip over a tag, add a `!` directly after the opening tag.
192
214
 
193
215
  ```nunjucks
@@ -240,6 +262,6 @@ Rather than having to do multiple `{{ /echo }} ... {{ echo }}` statements, the p
240
262
  {{ if someCondition }}
241
263
  <p>{{ getServerData }}</p>
242
264
 
243
- <p>Page built on: 04-08-2024</p>
265
+ <p>Page built on: 09-19-2024</p>
244
266
  {{ /if }}
245
267
  ```