1.0.0 • Published 3 years ago

eleventy-plugin-debug v1.0.0

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
3 years ago

eleventy-plugin-debug

INSTALLATION

npm install pdehaan/eleventy-plugin-debug

SETUP

// .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.
  2. json Wrapper for JavaScript's JSON.stringify() method. 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. This filter will also sort the returned array of key names for the specified object.

USAGE

Nunjucks

{{ collections.all | inspect }}
{{ page | json }}
{{ page | json(2) }}
{{ page | keys }}

LiquidJS

{{ collections.all | inspect }}
{{ page | json }}
{{ page | json: 2 }}
{{ page | keys }}

11ty.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) }