Skip to content

Pass data to nunjucks template #53

Description

@devaex

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions