扩展Handlebars.js模板 [英] Extending Handlebars.js templates

查看:102
本文介绍了扩展Handlebars.js模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法扩展Django中的模板?我的基本模板有一个标题,只需要几页。我想改变其他模板。



类似于

  {%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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆