Search code examples
mysqlnode.jsexpresshandlebars.js

Understanding the Basics behind Handlebars, Express, and Node.js


I've been struggling to understand Handlebars ever since I was introduced to it in class. I've researched different resources and videos (e.g., YouTube, StackOverflow, etc.) to try and learn more about it, but I still feel like I'm not getting it.

Could somebody please either explain to me what Handlebars is in their own terms or send me resources they found helpful when learning it?

Thanks!


Solution

  • handlebars.js is a templating engine which allows dynamic data to be mixed in with your HTML code. Templating engines were created due to complex projects requiring a lot of dynamic HTML manipulation. Previously, software developers created new chunks of HTML code and dynamically inserted them into the DOM using Javascript. This eventually became unwieldy and difficult to maintain. Also, it lead to repetition of code. To solve this issue, templating engines allowed one to create predefined templates to be used in multiple locations without repeating the code. Templates are like “macros”; wherever they are used, the code in them is inserted at that place. They also help to keep your html away from your javascript files, thereby increasing the readability and re-usability of your code. For a more comprehensive explanation see this blog post

    The best resource to learn handlebars.js is their documentation