Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comments in Jade/pug

Tags:

node.js

pug

I tried making comments in Jade/pug, but the comments render as text in the HTML. This is my code:

doctype html  html(lang='en')     body         / This should be a comment 

What am I doing something stupid?

like image 766
Randomblue Avatar asked Dec 16 '11 22:12

Randomblue


People also ask

How do you comment on a pug?

Simply add a hyphen ( - ) to the start of the comment. These are only for commenting on the Pug code itself, and do not appear in the rendered HTML.

How do you comment on Jade?

As written in the comment documentation, you can either use // which will translate to a HTML comment or //- which won't be visible in the outputted HTML code.

What is pug and Jade?

js, also known as PUG, is a Javascript library that was previously known as JADE. It is an easy-to-code template engine used to code HTML in a more readable fashion. One upside to PUG is that it equips developers to code reusable HTML documents by pulling data dynamically from the API.

How do you use Pug variables?

The names of the variables in your Pug file become siteColors and siteNames . To set the entirety of an HTML element equal to a variable, use the equals operator = to do so. If your variable needs to be embedded inline, use bracket syntax #{} to do so.


2 Answers

As written in the comment documentation, you can either use // which will translate to a HTML comment or //- which won't be visible in the outputted HTML code.

like image 103
alessioalex Avatar answered Oct 06 '22 22:10

alessioalex


In jade we use //- for comment. If you are trying to comment a block, make sure it should be indented properly like in below example-

doctype html  html(lang='en')     body         //-              This should be a comment             Indent correctly for block content 
like image 40
IRSHAD Avatar answered Oct 06 '22 21:10

IRSHAD