pug
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
This function is equivalent to pug.render
- it takes a Pug template string and renders it to an HTML string. import(npm:pug)
doesn't work in Val.Town due to Pug's usage of new Function
, which is forbidden for security reasons, so this function uses Val.Town's eval
API instead.
const myEndpoint = async (req: express.Request, res: express.Response) => {
const html = await @wilt.pug("p Hello #{name}!", {name: "Pug"});
res.status(200);
res.send(html);
}