This content originally appeared on DEV Community and was authored by All-time-dev
What is Pug HTML for beginners | All-time-dev?
Today, we are going to know about PUG which is a very important topic for you if you are a backend developer we will know the history of PUG, what is a pug and its uses what are template engines, and more. So, if you are interested and if you like our today's post then share it with your developer friends. So, that they can also gain some knowledge about PUG.
What is PUG?
Pug is a template engine for NODE JS means that if you write any PUG code then it will compile into HTML and its syntax will become simple which will help you understand your code better and eventually, it will increase productivity while coding and it also helps in writing reusable HTML code and it also helps in pulling data from a database while using an API from Rapid Apis or any other site but if you don't know what is a template Engine then it enables you to use Static template files on your web app. At Runtime means Node JS which is a JS(JavaScript) runtime. In this case, Pug which is a template engine will replace the variables in the file with actual values and will transform the file into an HTML file which helps you to design an HTML page and will also help you make it dynamic easily if you are using NODE JS and Mongo DB. So, simple Pug is a template engine for NODE JS which helps you to write HTML in the backend for a better understanding of code and easy reusability, and if you are thinking that if I am writing Node JS then can we only use PUG with Node JS then no we can also use with PHP, Python and several other languages and different languages have there different template engines like Python have its own template engine named Mako and JavaScript also has its own template engine named Jade/Pug, ejs (Embedd JavaScript)and some template engines also supports more than one language like Mustache which supports Ruby, JavaScript, Python, Erlang, Objective-C, Go, Lua, Scala, Node JS, Python, Java, .Net, Android, C++, C, C# and more and there is a important fact about Pug is that its old name was Jade which was changed into pug due to a trademark.
Top 5 tools which are integrable with Pug
Pug is very awesome and it has some integrable with some tools that you can use to increase your productivity and to use it for more uses like creating backend, for generating HTML websites, charting and more.
- Lad which is a Node JS framework
- Node JS which is JavaScript Runtime
- Prepros which is a compiler
- Squido which is a HTML website generator
- Anychart for charting
Popular companies using Pug
As Pug is very popular for serving dynamic content with Node JS then there are a lot of companies who is using Pug for growing their business like -
- Glovo
- Coursera
- 1mg
- Chiper
- Shimo website
- Barogo
- Accenture
Top 10 template engines rather than Pug
Pug is a very popular JavaScript template engine but there some more template engines which are even more better than Pug. Now, I will tell only the names of those template engines but if you want a complete post on that topic then you can comment below. I will definitely create a post on that topic.
- Mustache.
- Underscore Templates
- Embedded JS Templates
- HandlebarsJS.
- NunJucks
- UnderScore JS
- Webix
- Hogan.JS
- Swig
- Marko
So, these are some of the popular template engines rather than Pug HTML that you can use as an alternative all of them are very good.
Is using Pug better than using HTML and React?
Many people have doughts that why should we use Pug instead of just using HTML which every web developer already knows instead of learning template engines which is new for us then the simple answer is that Pug is more powerful and provides features like conditions, loops, included, mixins like SASS that we can render on reference data or whenever when the users inputs data and it natively supports JavaScript as it is both a JavaScript library and also a JavaScript template engine and an important reference that I have given you in the introduction is that, Pug is important to make website dynamic then yes its very important as if you want to make a website dynamic then at that time you must need Pug to serve dynamic content with NODE JS. So, in this case using Pug with Node JS will be better idea then using HTML with it. but if we choose to use Pug instead of React that's not a good idea as React JS is not only a template engine like Pug JS it is also framework that you can use to create web apps frontend and everyone knows that if you want to create a web app then the best stack is MERN STACK which includes React with Node JS, Express JSand Mongo DB. So, in this case if you want to create a web app then I would recommend using React JS.
To continue reading the post visit https://all-time-devlopment.blogspot.com/2022/01/what-is-pug-html-for-beginners-all-time.html
This content originally appeared on DEV Community and was authored by All-time-dev
All-time-dev | Sciencx (2022-01-23T08:03:28+00:00) What is Pug HTML for beginners | All-time-dev?. Retrieved from https://www.scien.cx/2022/01/23/what-is-pug-html-for-beginners-all-time-dev/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.