Using Inline Partials and Decorators with Handlebars 4.0
Handlebars version 4.0 landed in September 2015 and brought two major new features with it: Inline Partials and Decorators. In this article, we’re going to take a look at both features, explain their syntax and when you should use them. By its end, you should feel comfortable using both features to take your templating game to the next level!
Partials are a common templating concept not unique to Handlebars. The idea behind it is to create templates that are likely to be re-used, separate them into their own file (a Partial), and then use them in different templates. You may think at Partials as a simple a tool to modularize your templates.
Handlebars.registerPartial(). Finally, partials have to be separated from the templates where they’re being used. This can be a boon if your templates are large, but can also make it difficult for developers to fully understand the output of a template. They’ll need to switch between many different files before understanding the full output.
All these issues shape the way developers use partials. They end up being reserved just for the largest chunks of reusable code.
Continue reading %Using Inline Partials and Decorators with Handlebars 4.0%