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.
Related Reading
Guides and comparisons from the Greptile content library
10 Powerful Code Quality Tools That Catch Bugs Before Deployment
We tested 10 code quality tools that catch bugs before production. Detailed comparison with real-world examples, pricing, and ROI analysis for dev teams.
What is agentic coding? Benefits, risks, and best tools to consider
What engineering leaders need to know about agentic coding: how it differs from AI coding and vibe coding, how it works, the benefits and risks, and the tools worth evaluating.
Best CodeRabbit Alternatives for Smarter AI Code Reviews in 2026
7 powerful CodeRabbit alternatives ranked by real dev teams. Feature comparison, pricing analysis, and honest reviews to find your perfect AI code reviewer.
Greptile Ranks #1 on Martian's AI Code Review Benchmark
Greptile ranks #1 on Martian's independent online AI code review benchmark, leading all evaluated tools in F1 score and precision with near-leading recall.