fastify / fastify/help

How do I pass data to the Eta View Layout?

Open
#819 0 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
No language data
Stars
68
Forks
8
Avg merge
11h 2m
Merged PRs (30d)
2

Description

Hello there,
I want to pass some data to the layout template but I have no idea how.
The "intuitive one" doesn't work.

I want to create a multi-language website and use a lang.json file to do it.
For now I'm trying to change the title of the layout but this doesn't work at all.

index.js
```js
app.register(require("@fastify/view"), {
engine: {
eta: require("eta")
},
root: path.join(__dirname, "views"),
layout: "layout.eta",
propertyName: "render"
})
```

layout.eta
```html




<% it.title %>

layout


<% it.body %>

```

home.eta
```html

home


```

I also tried `<% layout("views/layout.eta", {it}) %>`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.