Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pdehaan/eleventy-plugin-debug
A collection of debugging filters for Eleventy projects.
https://github.com/pdehaan/eleventy-plugin-debug
eleventy eleventy-plugin
Last synced: 30 days ago
JSON representation
A collection of debugging filters for Eleventy projects.
- Host: GitHub
- URL: https://github.com/pdehaan/eleventy-plugin-debug
- Owner: pdehaan
- Created: 2021-05-29T15:15:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-29T15:42:43.000Z (over 3 years ago)
- Last Synced: 2024-12-17T10:12:11.571Z (about 1 month ago)
- Topics: eleventy, eleventy-plugin
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eleventy-plugin-debug
## INSTALLATION
```sh
npm install pdehaan/eleventy-plugin-debug
```## SETUP
```js
// .eleventy.js
const debug = require("eleventy-plugin-debug");module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(debug);
return {};
};
```This plugin will add the following new global filters which will help with debugging:
1. `inspect` — Wrapper for Node's native [`util.inspect()` method](https://nodejs.org/api/util.html#util_util_inspect_object_options).
2. `json` — Wrapper for JavaScript's [`JSON.stringify()` method](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). This filter takes one optional argument which is a string or number value to use for indentation, if you want pretty printed JSON objects.
3. `keys` — Wrapper for JavaScript's [`Object.keys()` method](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/keys). This filter will also sort the returned array of key names for the specified object.## USAGE
### Nunjucks
```njk
{{ collections.all | inspect }}
{{ page | json }}
{{ page | json(2) }}
{{ page | keys }}
```### LiquidJS
```liquid
{{ collections.all | inspect }}
{{ page | json }}
{{ page | json: 2 }}
{{ page | keys }}
```### 11ty.js
```js
${ this.inspect(data.collections.all) }
${ this.json(data.page) }
${ this.json(data.page, 2) }
${ this.keys(data.page) }
${ this.json(this.keys(data.page), 2) }
```