Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,29 @@ async function fastifyHotwire (fastify, opts) {

async function render (file, data) {
file = join(templates, file)
const html = await pool.runTask({ file, data, fragment: false })
const html = await pool.run({ file, data, fragment: false })
this.type('text/html; charset=utf-8')
this.send(html)
return this
}

async function turboSend (that, action, file, target, data) {
const html = await pool.runTask({ file: join(templates, file), data, fragment: true })
const html = await pool.run({
file: join(templates, file),
data,
fragment: true
})
that.type('text/vnd.turbo-stream.html; charset=utf-8')
that.send(buildStream(action, target, html.trim()))
return that
}

async function generate (_that, action, file, target, data) {
const html = await pool.runTask({ file: join(templates, file), data, fragment: true })
const html = await pool.run({
file: join(templates, file),
data,
fragment: true
})
return buildStream(action, target, html).replace(/\n/g, '').trim()
}
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
}
],
"dependencies": {
"fastify-plugin": "^5.0.0",
"piscina": "^4.0.0"
"fastify-plugin": "^6.0.0",
"piscina": "^5.0.0"
},
"devDependencies": {
"@fastify/cookie": "^11.0.1",
Expand Down
Loading