Skip to content

Instantly share code, notes, and snippets.

@rayepeng
Created June 8, 2023 05:00
Show Gist options
  • Save rayepeng/97d0395b40576687086966897ddf7dab to your computer and use it in GitHub Desktop.
Save rayepeng/97d0395b40576687086966897ddf7dab to your computer and use it in GitHub Desktop.
// npm install pug
const pug = require('pug');
// definte template
const template = `
h1 Hello, #{name}!
`;
// compilte template
const compiledTemplate = pug.compile(template);
// render template
const data = { name: 'John' };
const html = compiledTemplate(data);
console.log(html);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment