Node.js Project to Convert PUG Template to HTML Using pug-to-html CLI Library in Javascript Full App For Beginners

Node.js Project to Convert PUG Template to HTML Using pug-to-html CLI Library in Javascript Full App For Beginners

 

Welcome folks today in this blog post we will be converting pug to html using the pug-to-html library in javascript. All the source code of the application is given below.

 

 

 

Get Started

 

 

 

In order to get started we need to install the pug-to-html library globally inside your computer by issuing the npm command

 

npm i -g pug-to-html

 

After installing this command you will be able to use this library globally inside your system.

 

Now you need to create a views directory inside which you need to create a index.pug file and copy paste the pug code

 

 

index.pug

 

 

.card.text-center
  .card-header Bootstrap 4 card example
  .card-body
    .card-title Hello World, this is PugHtml
    i.fa.fa-home.fa-2x.text-primary
  .card-footer.text-muted powered by Bibooki

 

 

 

Now we will convert this file by using this cli library. So we need to issue the following command to convert the index.pug which is there inside the views directory and convert to index.html.

 

See also  JavaScript Program to Check if An Array Contains a Specified Value Using indexOf() Method Full Project For Beginners

 

pug-to-html views

 

 

Here views is the directory in which all the pug files are present

 

And then if you want to help regarding all the commands inside the cli library

 

pug-to-html -h

 

 

 

Leave a Reply