Skip to content

Instantly share code, notes, and snippets.

@rayepeng
Created June 8, 2023 05:00
Show Gist options
  • Save rayepeng/5725007a95f927d5fe7ab97311f23576 to your computer and use it in GitHub Desktop.
Save rayepeng/5725007a95f927d5fe7ab97311f23576 to your computer and use it in GitHub Desktop.
// npm install handlebars
const handlebars = require('handlebars');
// define template
const template = `
<h1>Hello, {{name}}!</h1>
`;
// more progress, compile template
const compiledTemplate = handlebars.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