Paragraph with br Tag
Br tag is used to add single line break.We can directly add <br> in pug template or add br on new line in paragraph.Br tag is followed by the pipe “|” ,followed by the text content.
Syntax:
p paragraph content
br
| text content
Example 2: Below is an example of paragraph with <br> tag.
doctype html
html(lang="en")
head
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
title Paragraph
style.
body {
margin:1.5rem;
font-family: Times, serif;
}
h1,h3,i {
margin: 1rem ;
text-align: center;
color:green;
}
body
h1 Welcome to w3wiki
h3 Paragraph with br and italic tag
p Pug is a template engine for node.js and browsers to render dynamic reusable content. While writting the pug template one should consider the indentation.
br
| At compile time the template engine compiles our pug template code to HTML .
i Pug has many powerful features like conditions,loop,include and mixins using which we can render HTML code based on user input or reference data.
//app.js
const express = require("express");
const app = express();
const port = 3000;
app.set("view engine", "pug");
app.get("/", (req, res) => {
res.render("paragraph");
});
app.listen(port, () => {
console.log(`server is running at http://localhost:${port}`);
});
Output:
Paragraphs in Pug View Engine
Pug is a template engine for NodeJS and browsers, enabling dynamic content rendering. It compiles templates to HTML, supports JavaScript expressions for formatting, and facilitates the reuse of static pages with dynamic data. Its indentation-based syntax simplifies tag specification, enhancing readability.
Table of Content
- Paragraphs in Pug:
- Approach to Creating a Pug Paragraph:
- Paragraph with br tag: