Get started with nunjucks CDN
BSD-2-Clause licensed
Nunjucks is a lightweight and flexible template engine for Node.js.
Tags:- template
- templating
Stable version
Copied!
How to start using nunjucks CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with nunjucks CDN - cdnhub.io</title>
<script src="https://cdn.jsdelivr.net/npm/nunjucks@3.2.4/nunjucks.min.js"></script>
<script>
const nunjucks = require('nunjucks');
// Set up the environment and templates
const env = new nunjucks.Environment();
env.addTemplate('templates/example.html', __html__`
<p>Hello, {{ name }}!</p>
`);
// Compile the template with the given data
const renderedTemplate = env.render('templates/example.html', { name: 'John Doe' });
// Append the compiled template to the body
document.body.innerHTML += renderedTemplate;
</script>
</head>
<body>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!