gpt4 book ai didi

node.js - DustJS 扩展布局?

转载 作者:太空宇宙 更新时间:2023-11-04 01:11:31 25 4
gpt4 key购买 nike

在 Jade JS 中,扩展布局非常容易。假设有layout.jade,对于index.jade,只需执行以下操作:

extend layout

block content // content comes here

那就足够了。

我搜索了official guide但没找到怎么办。最相似的似乎是这样的:

{>partials}

但这仍然不是扩展布局。如何在DustJS中实现类似的事情?非常感谢。

最佳答案

我找到了解决方案...事实证明我没有足够仔细地阅读灰尘文档。

布局文件:

<html>
<head>
<title>{+title}Location of Title{/title}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js"></script>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.js"></script>
</head>
<body>
<header>
<h1 id="page-title" class="very-middle">{+title}Title Comes Here{/title}</h1>
</header>
<div id="content">
{+content}
Content Comes Here
{/content}
</div>

</body>
</html>

内容文件:

 {>layout/}

{<content}
{!
Content simply comes here
}
{/content}

所以重点是使用 {+placeHolder}、{>toExtend} 和 {

关于node.js - DustJS 扩展布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16848500/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com