Navigate:
~$PUG0.0%

Pug: HTML template engine for Node.js

Whitespace-sensitive template engine compiling to HTML for Node.js with Haml-inspired syntax.

LIVE RANKINGS • 02:15 PM • STEADY
OVERALL
#417
21
DEVELOPER TOOLS
#88
9
30 DAY RANKING TREND
ovr#417
·Devel#88
STARS
21.9K
FORKS
1.9K
7D STARS
+3
7D FORKS
0
See Repo:
Share:

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.

Pug

1

Whitespace Syntax

Uses indentation and whitespace to define HTML structure instead of closing tags. This approach reduces markup verbosity and enforces consistent formatting.

2

JavaScript Integration

Supports embedded JavaScript expressions, conditionals, and loops directly within templates. Variables and functions can be passed to templates during compilation.

3

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>


vpug@3.0.3

Validate `templateName` and `globals` are valid JavaScript identifiers to prevent possible remote code execution if un-trusted user input is passed to

  • Update pug-code-gen with the following fix: (#3438)
vpug-error@2.1.0

pug-error@2.1.0

  • Convert to TypeScript (#3355)
vpug-code-gen@3.0.3

pug-code-gen@3.0.3

  • Validate `templateName` and `globals` are valid JavaScript identifiers to prevent possible remote code execution if un-trusted user input is passed to the compilation options (#3438)


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers