- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我刚开始使用 Express 浏览 Node,最后让 Consolidate JS 正常工作,按照 Consolidate JS Github page 上的说明使用 Mustache 作为模板 View 系统。 .
Mustache 加载正确,但我现在想知道如何在模板呈现中包含布局文件。默认的 Jade 系统加载 layout.jade 文件中 .render 方法的内容。我只是想知道如何使用 Mustache 做同样的事情。非常感谢任何帮助!
代码:
index.js
exports.index = function(req, res){
res.render('index', { title: "Work pl0x?" });
});
index.mustache
我只希望 index.mustache 内容出现在下面代码的“{{content}}”部分 (layout.mustache)。我该怎么做?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>Project Name | {{title}}</title>
<link href="/stylesheets/style.css" rel="stylesheet" />
</head>
<body>
{{content}}
</body>
</html>
最佳答案
获得这种行为(某种)的一种方法是:
exports.index = function(req, res){
res.render('layout', { title: "Work pl0x?", partials: { content: "index" });
});
然后在你的layout.html中这样写
<body>
{{>content}}
</body>
关于node.js - 通过 Consolidate 和 Mustache 在 Express 中使用布局 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12209607/
简要描述预期的设计:我想要一个导航菜单,在悬停时显示内容。但我也在寻求灵 active 和简单性。因为每个 nav 元素的行为方式相同,我想 javascript 和 css 可以用标识每个 nav
不太确定如何描述这个,但我有一个我喜欢玩的文字游戏,我想将其实现为计算机程序。 基本要点是您查看字母的值 (A=1..Z=26),并将字母合并为尽可能少的字母,并且尽可能彼此接近。 举个例子: s t
我在处理某些代码时喜欢频繁(甚至随机)提交,因为如果我在某个地方搞砸了,我总是可以回滚我的更改。 然而,当我决定将所有更改推送到主存储库时,我不希望人们看到所有随机提交,因为其中一些对他们来说真的毫无
Springer 的 Consolidated Ada Reference Manual 2005 Edition (ISO/IEC 8652:2007(E), Ed. 3) 和 Annotated
伪代码来自 Introduction to Algorithms 指出: for each node w in the root list of H link trees of the same
假设我们有一个数据结构: class Segment{ float startTime; float endTime; } 我们有一堆片段,其中一些具有重叠的持续时间。合并这些段以使其
我目前正在尝试创建一个系统,用户可以在其中选择一些引用表格的复选框并获取所选表格的合并表格。到目前为止,我的系统生成复选框,检查哪些复选框被勾选,将该列表传递给另一个函数,该函数应该读取已选择表的范围
是否有任何软件包/库可以为生产环境生成合并的、缩小的 JavaScript 文件,同时在开发环境中保留原始文件/引用原样(以便开发人员可以独立工作)? JAWR does this (以及更多)用于
我正在尝试减少我必须在上下文菜单中使用的信号量。菜单由切换程序运行模式的 Action 组成,因此插槽进行的操作非常简单。引用 QMenu::triggered 上的文档, Normally, you
您好,我正在尝试查找我的 Iphone 4 IOS 7.0.4 的跟踪历史记录。 好吧,我在本地备份中找到了 consolidated.db 文件,但里面没有 CellLocation 表。 我用这个
我显然可以自己做一些有限的测试,但我希望听到一些在至少中等规模的网站上有实际经验的人的意见。 每个用于优化站点/带宽的“前 10 名”列表中的两项是: 将尽可能多的 JS 和 CSS 合并到一个文件中
我发现对于我的示例来说,两个数组的串联/追加是一个过于繁琐的过程。但是如何在单个 block 中使用 For Each 迭代两个工作表数组(如何缩短以下代码)? arr1 = Array("Sheet
我正在尝试让包含子查询的 BigQuery 查询结果返回一行而不是两行。我正在查询日志文件,所以我需要的所有数据都在同一个字段中。该字段中的数据示例如下: /?cv=p15.0.9350&ctyp=s
我目前正在使用 swig 和 consolidate,效果很好: app.engine('server.view.html', consolidate['swig']); 现在,我想调整swig op
必须有更好的方法来做到这一点,请帮助我 这是我必须清理的一些数据的摘录,其中有几种“重复”行(并非所有行都是重复的): df= LoanID | CustomerID | LoanStatus | C
我从这个论坛学到了很多东西,提前致谢。基本上,我试图为多个表的数据库查询的结果做“脚注”。我的表格具有几种生物 Material 中每种生物 Material 的“引用书目”,但我无法以更具可读性的方
elements
我有多个 xml 实例,类似于以下内容: FOOBAR Values: 000 - 999 FOOBAR FOOBAR FOOBAR FOOBAR V
我在 Node.js 上使用 Express.js,并用“{{ }}”括号标记参数位置,但默认使用下划线“”。 app.engine('html', cons.underscore); // set
我有一个根目录和一个子目录。我计划将函数放在 libfunc.o 下的子目录中 这个libfunc.o应该与顶级目录中的其他目标文件合并。但我收到错误: $make all cd folder;
我有一个从 csv 导入的 pandas 数据框,格式如下: IP 操作系统端口协议(protocol) ... 0.0.0.0 Linux 5000 TCP ... 0.0.0.0 Linux 50
我是一名优秀的程序员,十分优秀!