扩展Handlebars.js模板 [英] Extending Handlebars.js templates
问题描述
类似于
{%extendsbase.html%}
...
{%endblock%}
我正在使用Ember.js。
据我所知,这个符号不存在,我还没有看到在handlebars模板层上继承的概念。
但是,我可以想到两种方式来实现你想要的,
/ strong>使用 {{partial}}
帮助器 http://emberjs.com/guides/templates/rendering-with-helpers/
{{部分}}
帮助器可以渲染头部分,它只能包含在需要标题的页面的那些模板上。
2。使用布局 http://emberjs.com/guides / views / adding-layouts-to-views /
有两个布局一个标题,另一个没有它,然后在页面/视图上指定需要标题相应的布局使用 layoutName
属性。
Is there a way to extend templates like in Django? My base template has a header that only needs to be a few pages. I'd like to change that for the the other templates.
Something similar to
{% extends "base.html" %}
...
{% endblock %}
I'm using Ember.js.
As far as i know this notation does not exist, also i haven't seen the concept of inheritance on handlebars templates layer.
However, i can think of two ways to achieve what you want,
1. using the {{partial}}
helper http://emberjs.com/guides/templates/rendering-with-helpers/
The {{partial}}
helper can render the header part and it can be included only on those templates of the pages that require the header.
2. using layouts http://emberjs.com/guides/views/adding-layouts-to-views/
Have two layouts one with the header and another without it, then specify on the pages/views that need the header the corresponding layout using the layoutName
property.
这篇关于扩展Handlebars.js模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!