Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jan 5, 2023
1 parent ea33177 commit 8597527
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
22 changes: 1 addition & 21 deletions src/docs/config.md
Expand Up @@ -205,27 +205,7 @@ module.exports = function(eleventyConfig) {

### Default template engine for global data files

The `dir.data` global data files run through this template engine before transforming to JSON. Read more about [Global Data Files](/docs/data-global/).

| Data Template Engine | |
| --- | --- |
| _Object Key_ | `dataTemplateEngine` |
| _Default_ | `"liquid"` (before 1.0) |
| _Default_ | `false` (1.0 and above) |
| _Valid Options_ | A valid [template engine short name](/docs/languages/) or `false` |
| _Command Line Override_ | _None_ |

#### Example

{% codetitle ".eleventy.js" %}

```js
module.exports = function(eleventyConfig) {
return {
"dataTemplateEngine": "njk"
}
};
```
{% callout "warn" %}<strong>Feature Removal</strong>: <a href="/docs/data-preprocessing/">This feature was removed in Eleventy 2.0.</a>{% endcallout %}

### Default template engine for Markdown files

Expand Down
33 changes: 28 additions & 5 deletions src/docs/data-preprocessing.md
Expand Up @@ -6,14 +6,35 @@ eleventyNavigation:
---
# Global Data File Preprocessing

{% callout "warn" %}<strong>Deprecation Warning</strong>: This feature is deprecated and will be removed in a future version of Eleventy. You can use <a href="/docs/data-js/">JavaScript Data Files</a> or <a href="/docs/data-computed/">Computed Data</a> instead.{% endcallout %}
{% callout "error" %}<strong>Feature Removal</strong>: This feature was removed in Eleventy 2.0. You can use <a href="/docs/data-js/">JavaScript Data Files</a> or <a href="/docs/data-computed/">Computed Data</a> instead.{% endcallout %}

* Starting in Eleventy 1.0, this feature is disabled by default: `dataTemplateEngine: false`
* Prior versions of Eleventy used Liquid preprocessing by default: `dataTemplateEngine: "liquid"`
The `dir.data` global data files run through this template engine before transforming to JSON. Read more about [Global Data Files](/docs/data-global/).

[Global JSON data files](/docs/data-global/) (*not template/directory data files*) can be optionally preprocessed with a template engine specified under the `dataTemplateEngine` configuration option. `package.json` data is available here under the `pkg` variable.
| Data Template Engine | |
| --- | --- |
| _Object Key_ | `dataTemplateEngine` |
| _Default_ | `"liquid"` (before 1.0) |
| _Default_ | `false` (1.0 and above) |
| _Valid Options_ | A valid [template engine short name](/docs/languages/) or `false` |
| _Command Line Override_ | _None_ |

For example, if your `dataTemplateEngine` is using `liquid` you can do this:
[Global JSON data files](/docs/data-global/) (*not template/directory data files*) can be optionally preprocessed with a template engine specified under the `dataTemplateEngine` configuration option.

## Example

{% codetitle ".eleventy.js" %}

```js
module.exports = function(eleventyConfig) {
return {
"dataTemplateEngine": "njk"
}
};
```

For example, if your `dataTemplateEngine` is using `njk` or `liquid` you can do this in any `*.json` files in your `_data` folder:

{% codetitle "_data/myfile.json" %}

{% raw %}
```json
Expand All @@ -22,3 +43,5 @@ For example, if your `dataTemplateEngine` is using `liquid` you can do this:
}
```
{% endraw %}

`package.json` data is available here supplied by Eleventy in the `pkg` variable.

0 comments on commit 8597527

Please sign in to comment.