Mustache
模板语言:
- Ant Design
*.tsx - Astro
*.astro - Bootstrap
*.html - Chakra UI
*.tsx - Docsify
*.md - Docusaurus
*.mdx - ESBuild
*.js - Eleventy
*.11ty.js - Gatsby
*.js - GitBook
*.md - Gridsome
*.vue - Hexo
*.ejs - Hugo
*.html - Jekyll
*.html - Mantine
*.tsx - Material-UI
*.js - MkDocs
*.md - Next.js
*.js - Nuxt.js
*.vue - Parcel
*.html - Remix
*.tsx - Rollup
*.js - Storybook
*.stories.js - Sphinx
*.rst - SvelteKit
*.svelte - SWC
*.ts - Tailwind CSS
*.css - Turbopack
*.ts - Vite
*.ts - VitePress
*.md - VuePress
*.vue - Webpack
*.js - 自定义框架
*.*
| Eleventy 简称 | 文件扩展名 | npm 包 |
|---|---|---|
mustache |
.mustache |
mustache |
| Eleventy 或插件版本 | mustache 版本 |
|---|---|
@11ty/eleventy@0.x |
mustache@2.x |
@11ty/eleventy@1.x |
mustache@4.x |
@11ty/eleventy@2.x |
mustache@4.x |
@11ty/eleventy@3.x 及更新版本 |
N/A |
@11ty/eleventy-plugin-mustache@1.x |
mustache@4.x |
您可以覆盖 .mustache 文件的模板引擎。更多信息请阅读更改模板的渲染引擎。
安装
.mustache 模板语言在 v3 中已从 Eleventy 核心中移出,现在需要插件安装。
npm install @11ty/eleventy-plugin-mustache
添加到您的配置文件:
eleventy.config.js
import mustachePlugin from "@11ty/eleventy-plugin-mustache";
export default function (eleventyConfig) {
eleventyConfig.addPlugin(mustachePlugin);
}
const mustachePlugin = require("@11ty/eleventy-plugin-mustache");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(mustachePlugin);
}
使用更多选项:
eleventy.config.js
import mustache from "mustache";
import mustachePlugin from "@11ty/eleventy-plugin-mustache";
export default function (eleventyConfig) {
eleventyConfig.addPlugin(mustachePlugin, {
// 覆盖 `mustache` 库实例
eleventyLibraryOverride: mustache,
});
}
const mustache = require("mustache");
const mustachePlugin = require("@11ty/eleventy-plugin-mustache");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(mustachePlugin, {
// 覆盖 `mustache` 库实例
eleventyLibraryOverride: mustache,
});
}
支持的功能
| 功能 | 语法 |
|---|---|
| ✅ 部分模板 | {{> user}} 查找 _includes/user.mustache。不处理 include 文件中的前置内容。 |
| 🚫 部分模板(相对路径) | 尚不支持:{{> ./user}} 在模板当前目录中查找 user.mustache。 |