1

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).

Falcon
19.4k4 gold badges82 silver badges93 bronze badges
asked Sep 8, 2011 at 19:34
3
  • Your question is incredibly unclear. Also this has nothing to do with php, please remove that tag. Commented Sep 8, 2011 at 19:40
  • 1
    "Suggest some of them" Yessir! Commented Sep 8, 2011 at 19:54
  • @Jose - that was a word for word copying from a test or homework assignment, thus the imperative wording Commented Sep 8, 2011 at 20:21

2 Answers 2

3

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 ;)).

answered Sep 8, 2011 at 19:59
2

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.

answered Sep 8, 2011 at 20:03
2
  • Thanks for your reply. please suggest some javascript templates Commented Sep 9, 2011 at 6:42
  • Embeddedjs is a library to help you with templates. And TrimPath is an example of JS template. Commented Sep 9, 2011 at 6:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.