Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/web-alchemy/eleventy-plugin-twig
https://github.com/web-alchemy/eleventy-plugin-twig
eleventy eleventy-plugin template-engine twig
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/web-alchemy/eleventy-plugin-twig
- Owner: web-alchemy
- Created: 2022-06-27T05:26:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-08T07:14:35.000Z (about 1 year ago)
- Last Synced: 2025-01-24T03:01:50.452Z (18 days ago)
- Topics: eleventy, eleventy-plugin, template-engine, twig
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Eleventy Plugin for Twig
This plugin adds support for [Twig.js](https://github.com/twigjs/twig.js) template engine.
## Installation
```
npm install @web-alchemy/eleventy-plugin-twig
```## Using
```javascript
const TwigPlugin = require('@web-alchemy/eleventy-plugin-twig')module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(TwigPlugin, {
// here you can extend Twig (add your own filter, functions, tags, etc.).
// https://github.com/twigjs/twig.js/wiki/Extending-twig.js
// https://github.com/twigjs/twig.js/wiki/Extending-twig.js-With-Custom-Tags
init: async function (Twig) {
Twig.cache(false)
},twigOptions: {
strictVariables: true,
autoescape: true,
allowInlineIncludes: true,
// https://github.com/twigjs/twig.js/wiki#namespaces
namespaces: {
includes: 'src/_includes',
layouts: 'src/_layouts',
}
},
// here you can set a condition for skipping the template rendering
skipRenderCondition: async function (inputContent, inputPath, config) {
return false // function should return `true` for skipping
},
})
}
```## References
- [Twig.js](https://github.com/twigjs/twig.js/)
- [Twig template language reference](https://twig.symfony.com/)
- [Another implementation of Eleventy Plugin for Twig](https://github.com/factorial-io/eleventy-plugin-twig)