Skip to navigation Skip to main content
11ty Logo Sustainability Fundraising
Eleventy
Eleventy Documentation
Stable
2.0.1
Canary
3.0.0-alpha.16
Toggle Menu
Eleventy 5.81s
Remix 40.14s

Global Data File Preprocessing

ERROR:
该功能已废弃:该功能在 Eleventy 2.0 版本中已被删除。你可以改用 JavaScript 数据文件(Data Files)经计算的数据(Computed Data) 来替代此功能。

The dir.data global data files run through this template engine before transforming to JSON. Read more about Global Data Files.

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 or false
Command Line Override None

Global JSON data files (not template/directory data files) can be optionally preprocessed with a template engine specified under the dataTemplateEngine configuration option.

Example Jump to heading

Filename .eleventy.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:

Filename _data/myfile.json
{
"version": "{{ pkg.version }}"
}

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