Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Ceil-Ian MaralitFront End Web Development Techdegree Graduate 19,434 Points
Purpose of pug
Hi! I was just wondering what is the main purpose of templates? I mean, we can link different parts of our website using just HTML, right? So, what's really coming into my mind right now is using this as a response on a form. Like when they hit the submit button etc..
Thanks in advance!
Ari Misha19,323 Points
Hiya there! The main purpose of using pug template or any other templating engine is to control your server-side rendering content. For example, if you wanna render a file or JSON, when the end-user navigates to a certain URL, you can let server to decide what needs to be rendered, right? But the question is how to get the hold on a DOM element? Well, it can be easily done within your script tags or just link a script file to the rendered HTML. You can't perform DOM related operation in your server unless you do it on the front end where you could actually hold on to the window Object.
I hope it helped!