vituum
vituum copied to clipboard
Pass data to nunjucks template
Very good plugin.
I'm using it with nunjucks.
Is there any way to pass data to a nunjucks template?
I know there is an option to put the json inside data/... Or pass in vite.config.js as globals parameters.
But, I'm referring to passing the data via javascript at compile time.
Example:
<html lang="en">
<head>
<script type="module" src="myscript.js"></script>
<title>{{ title }}</title>
</head>
<body>
...
</body>
</html>
Is there a way for myscript.js to provide the title variable for the template?
As the template is automatically rendered by vite/vituum, I didn't find a way to do this.