Pug: HTML template engine for Node.js
Whitespace-sensitive template engine compiling to HTML for Node.js with Haml-inspired syntax.
Learn more about Pug
Pug is a template engine that transforms indentation-based markup into HTML output. It uses whitespace and indentation to define document structure, eliminating the need for closing tags while supporting JavaScript expressions, conditionals, and loops. The engine compiles templates into JavaScript functions that can be executed with data to generate HTML. Pug is commonly used in web applications for server-side rendering, static site generation, and client-side templating.
Whitespace Syntax
Uses indentation and whitespace to define HTML structure instead of closing tags. This approach reduces markup verbosity and enforces consistent formatting.
JavaScript Integration
Supports embedded JavaScript expressions, conditionals, and loops directly within templates. Variables and functions can be passed to templates during compilation.
Modular Architecture
Built with separate packages for lexing, parsing, code generation, and runtime execution. This modular design allows for customization and integration with different build systems.
const pug = require('pug');
// Compile a template function
const template = pug.compile('p Hello #{name}!');
const html = template({ name: 'World' });
// Or render directly
const html2 = pug.render('p Hello #{name}!', { name: 'World' });
console.log(html); // <p>Hello World!</p>Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
Fastfetch
High-performance CLI system information display written in C.
Playwright MCP
Accessibility tree-based browser automation for LLMs.
nvm
Per-user Node.js version manager for switching between installed versions via command line on POSIX-compliant shells.
StatsD
UDP/TCP metrics collector with pluggable backend support.
spdlog
Fast C++ logging with flexible sinks and fmt formatting.