Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass data to nunjucks template #53

Open
devaex opened this issue Aug 1, 2024 · 0 comments
Open

Pass data to nunjucks template #53

devaex opened this issue Aug 1, 2024 · 0 comments

Comments

@devaex
Copy link

devaex commented Aug 1, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant