Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript template inheritance

In the Django framework, web page templates can inherit from other templates. In your child template, you define blocks of code which override like-named blocks in parent templates. I'm guessing there are other back-end templating systems which also work this way, but Django is the one I'm familiar with.

Do any of the existing javascript template systems support django-style inheritance?

like image 851
morgancodes Avatar asked Sep 07 '10 00:09

morgancodes


People also ask

Can template class be inherited?

It is possible to inherit from a template class. All the usual rules for inheritance and polymorphism apply. If we want the new, derived class to be generic it should also be a template class; and pass its template parameter along to the base class.

What is template inheritance?

Template inheritance allows you to build a base “skeleton” template that contains all the common elements of your site and defines blocks that child templates can override. Sounds complicated but is very basic. It's easiest to understand it by starting with an example.

Does JavaScript support inheritance?

In JavaScript, an object can inherit properties of another object. The object from where the properties are inherited is called the prototype. In short, objects can inherit properties from other objects — the prototypes.

What is template inheritance in pug?

Pug's template inheritance is a powerful feature that allows you to split complex page template structures into smaller, simpler files. However, if you chain many, many templates together, you can make things a lot more complicated for yourself.


1 Answers

What you're looking for if you want template inheritance and DTL syntax, is Nunjucks :

http://mozilla.github.io/nunjucks/

like image 153
evaisse Avatar answered Oct 20 '22 19:10

evaisse