⚡️
🌱
ViteTwig
import twig from '@vituum/vite-plugin-twig'
export default {
plugins: [
twig({
reload: true,
root: null,
filters: {},
functions: {},
extensions: [],
namespaces: {},
globals: {
template: 'path/to/template.twig'
},
data: '*.json',
filetypes: {
html: /.(json.html|twig.json.html|twig.html)$/,
json: /.(json.twig.html)$/
},
twig: {
compileOptions: {},
renderOptions: {}
}
})
]
}
Read the docs to learn more about the plugin options.
Basic usage
<!-- index.html -->
<script type="application/json" data-format="twig">
{
"template": "path/to/template.twig",
"title": "Hello world"
}
</script>
or
<!-- index.twig.html -->
{{ title }}
or
<!-- index.json.html or index.twig.json.html -->
{
"template": "path/to/template.twig",
"title": "Hello world"
}