What is the difference between templates and design patterns in JavaScript?
I read about the template method design pattern and now I wonder how it relates to JavaScript templates (if at all).
What is the difference between templates and design patterns in JavaScript?
I read about the template method design pattern and now I wonder how it relates to JavaScript templates (if at all).
Templates (in the Javascript world) are a method to display Javascript (model) data in an HTML (or other) view.
Design patterns are known (and battle tested) methods of solving common problems.
Really, Javascript templates could be construed as a design pattern (depending on who you ask ;)).
Design patterns are used to solve commonly encountered problems related to software design. Once you know how to solve a particular problem, when that problem presents again you can reuse the same approach you used before, the same pattern.
Patterns are not related to JavaScript only, but to every language.
The JavaScript Templates you are referring about may be a technique used to generate data in the document, originally called Micro-templating by the inventor, John Resig (jQuery).
Here's an article to better understand them.
And here's one for applying common design patterns in JS.