pug
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
pug-code-gen | 3.0.2 | 7.9 kB | MIT | prod | |
pug-filters | 4.0.0 | 3.59 kB | MIT | prod | |
pug-lexer | 5.0.1 | 13.38 kB | MIT | prod | |
pug-linker | 4.0.0 | 3.11 kB | MIT | prod | |
pug-load | 3.0.0 | 3.27 kB | MIT | prod | |
pug-parser | 6.0.0 | 7.75 kB | MIT | prod | |
pug-runtime | 3.0.1 | 6.39 kB | MIT | prod | |
pug-strip-comments | 2.0.0 | 2.39 kB | MIT | prod |
Pug is a high-performance template engine that's predominantly utilized for writing HTML. Implemented using JavaScript for Node.js and browsers, it adopts a clean, whitespace-sensitive syntax which allows you to write HTML in a terse and simple way. The engine has a strong focus on performance and offers powerful features to facilitate website development.
To utilize Pug, you need to first install it via npm by executing the command npm install pug
. After installation, you can use Pug for writing HTML markup in a simplified manner. Consider the following basic example:
doctype html
html(lang="en")
head
title= pageTitle
script(type='text/javascript').
if (foo) bar(1 + 5)
body
h1 Pug - Node template engine
#container.col
if youAreUsingPug
p You are amazing
else
p Get on it!
p.
Pug is a terse and simple templating language with a
strong focus on performance and powerful features.
This Pug code will be compiled to the following HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Pug</title>
<script type="text/javascript">
if (foo) bar(1 + 5)
</script>
</head>
<body>
<h1>Pug - Node template engine</h1>
<div id="container" class="col">
<p>You are amazing</p>
<p>Pug is a terse and simple templating language with a strong focus on performance and powerful features.</p>
</div>
</body>
</html>
To use the Pug API, you can invoke methods such as pug.compile
, pug.render
, and pug.renderFile
that can take a string of Pug or a file name, along with options and locals:
var pug = require('pug');
// compile
var fn = pug.compile('string of pug', options);
var html = fn(locals);
// render
var html = pug.render('string of pug', merge(options, locals));
// renderFile
var html = pug.renderFile('filename.pug', merge(options, locals));
The complete documentation for Pug is available at https://pugjs.org/. This includes a reference to its API, tutorials, and additional resources that will help you get started with Pug and master its features and usage in your web development projects.