Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 把手的模板继承_Javascript_Templates_Handlebars.js - Fatal编程技术网

Javascript 把手的模板继承

Javascript 把手的模板继承,javascript,templates,handlebars.js,Javascript,Templates,Handlebars.js,我正在尝试使用Handlebar将base.html中的模板继承到其他模板中,但我没有为此获得灵魂 请,谁能帮我做一个简单的演示。使用base.html,extend.html {% extends "base.html" %} {% block content %}<h1>Foobar!</h1>{% endblock %} 比如说,, Base.html <html><head></head> <body> {% bl

我正在尝试使用Handlebar将base.html中的模板继承到其他模板中,但我没有为此获得灵魂

请,谁能帮我做一个简单的演示。使用base.html,extend.html

{% extends "base.html" %}
{% block content %}<h1>Foobar!</h1>{% endblock %}
比如说,, Base.html

<html><head></head>
<body>
{% block content %}{% endblock %}
</body>
</html>

{%block content%}{%endblock%}
Extend.html

{% extends "base.html" %}
{% block content %}<h1>Foobar!</h1>{% endblock %}
{%extends“base.html”%}
{%block content%}Foobar!{%endblock%}
我需要在base.html中包含哪些文件?

//在我的节点服务器中:使用express和hbs
// in my node server: using express and hbs 
hbs.registerPartials(__dirname + '/built/development/templates');
app.get('/', function (req, res) {
  res.render('_base', {
    "STATIC_URL": app.get('STATIC_URL')
  });
});

// This is in my base template 
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" itemscope itemtype="http://schema.org/Article" xmlns:fb="http://ogp.me/ns/fb#"> <!--<![endif]-->
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# blog: http://ogp.me/ns/blog#">
    {{> _config_logged_out }}
    {{> _scripts }}
</head>
注册部分(uu dirname+'/build/development/templates'); app.get('/',函数(req,res){ res.render(“U base”{ “静态URL”:app.get(‘静态URL’) }); }); //这在我的基本模板中 {{>{u配置\ u注销} {{>{u脚本}
可以扩展部分以支持“块”,请参阅。

把手不提供开箱即用的模板继承

但是,有些库提供了执行模板继承所需的帮助程序。我最喜欢的是,它基于Pug和Django中的模板继承,并按照您的预期工作


还有一种工作方式稍有不同,但如果需要,它也可以运行客户端。

模板需要位于带有ID的脚本标记中。标题标签的文本不需要模板,它只是文本。您还没有解释extend.html和base.html之间的任何关系。