- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 jQuery 1.8.2 和 Dust.js v1.1.1 在 JavaScript 应用程序中实现 MVC 样式的模板。当我使用 {@gt}
逻辑助手时,我收到以下控制台错误:
Uncaught TypeError: Cannot read property 'gt' of undefined
我相信我的模板中使用了正确的语法:
<ul class="listview">
{#seasons}
<li>
<h3>{name}</h3>
<p class="desc">{id}</p>
{@gt key="months" value="0"}
<span class="count">{months}</span>
{/gt}
</li>
{/seasons}
</ul><!--// end .listview -->
这是 JSON 结构:
{
"seasons":[
{
"name":"Spring",
"id":"weklv7",
"months": 8
},
{
"name":"Summer",
"id":"lvuec5",
"months": 4
}
]
}
如果我从模板中删除 {@gt}
逻辑助手,错误就会消失,并且模板会作为 HTML 正确加载。例如:
<ul class="listview">
{#seasons}
<li>
<h3>{name}</h3>
<p class="desc">{id}</p>
<span class="count">{months}</span>
</li>
{/seasons}
</ul><!--// end .listview -->
非常感谢任何帮助,谢谢!
最佳答案
请密切关注提供的链接 smfoote。
为了在节点中“加载”灰尘助手,您需要的特定语法是:
var dust = require('dustjs-linkedin');
dust.helper = require('dustjs-helpers');
请注意,这不是链接上写的内容,链接文档表明这应该是带有“s”的 dust.helper(S)。
您根本不会在主要文档站点的任何地方找到该短语。
显然,这应该是连接事物的方式,这应该是完全直观的。
有时,我觉得那些未能记录他们对项目所做的重大更改的影响的人正在偷走我的生活。这个特殊的文档差距偷走了大约 5 个小时。
为了帮助那些同时运行 npm install dustjs-linkedin 和 npm install dustjs-helpers 并且想知道为什么它不能自动工作的人(因为它基本上是网站上所有文档所建议的) .当你在这里遇到这个错误时,我将重建你通常会遇到的错误:
if( dust.helpers[name]){
^
然后其中之一..
TypeError: Cannot read property 'if' of undefined
TypeError: Cannot read property 'math' of undefined
TypeError: Cannot read property 'eq' of undefined
TypeError: Cannot read property 'not eq' of undefined
TypeError: Cannot read property 'ne' of undefined
TypeError: Cannot read property 'lt' of undefined
TypeError: Cannot read property 'gt' of undefined
TypeError: Cannot read property 'select' of undefined
TypeError: Cannot read property 'size' of undefined
TypeError: Cannot read property 'tap' of undefined
TypeError: Cannot read property 'contextDump' of undefined
TypeError: Cannot read property 'idx' of undefined
TypeError: Cannot read property 'sep' of undefined
有趣的是,如果您将 dustjs-helpers 分配给“helpers”而不是“helper”,您会得到一个不同的错误:
undefined:1
").write("</form>").write("\n\n").helper("contextDump",ctx,{},null).write("\n\
^
TypeError: Cannot call method 'write' of undefined
编写一些代码来检测何时有人试图使用以“@”开头的东西并说..嘿你可能没有加载到你的帮助程序库......并使其在节点中工作是相当微不足道的和非节点上下文......或者他们可以修复文档。
我真诚地希望,我花额外的 15 分钟来拼凑一个 Google 可能会 Grok 的答案,可以为其他人节省我刚刚失去的 5 个小时。
-英尺
关于javascript - Dust.js 逻辑助手的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13326570/
当我尝试加载库 Raster 时,我收到如下错误: 错误:inDL(x, as.logic(local), as.logic(now), ...) 中的“raster”的包或命名空间加载失败:无法加载
当我尝试加载库 Raster 时,我收到如下错误: 错误:inDL(x, as.logic(local), as.logic(now), ...) 中的“raster”的包或命名空间加载失败:无法加载
望着help section about_Comparison_Operators of PowerShell我是这样理解的: PS C:\> $false,$false -eq $true PS C
我刚刚修改了旧代码,现在似乎没有任何效果。请您指导我哪里出错了。 一些不起作用的事情是: 以前,焦点始终停留在屏幕上唯一的输入字段上。 (现在不行了),代码中的 if else 条件也不起作用。 On
请帮我找到一个使用普通 'ol javascript 的解决方案(我无法使用外部框架)。此外,CSS :hover 选择器不适用于现实世界的实现。 注册事件发生的事情设置所有调用最后注册事件数组项。
我想创建一个软件来为残障 child 交通规划公交路线(及其最佳载客量)。 这些总线具有以下规范: m 个座位(最多 7 个 - 因为有司机和助理) o 轮椅“座位”(最多 4 个) 固定的最大负载量
有人能帮我吗?似乎我的 for 逻辑根本不起作用,因为它一直在上午 12:00 返回我的开始时间 这是我的代码 Sub forlogic() Dim i As Single Dim t
我正在尝试设置 OR两个切片器过滤器之间的逻辑。两个切片器来自相同的数据集。以下是更多详细信息: 我的源表: 带切片器的视觉效果: 我的目标是,如果我从切片器 1 和切片器 2 中选择任何值,我的视觉
我有以下 C 语句: int res = x & (x ^ y); 有没有办法做同样的事情,但每次只使用一次x和y? 例如: x | (~x & y) == x | y 最佳答案 是的,通过扩展 xo
我正在创建 Azure 逻辑应用程序以将新的 Sharepoint 文件添加到 Azure Blob。 Sharepoint 由我的公司运行,我使用我的凭据登录来为逻辑应用程序创建 Sharepoin
我有一个问题要求为给定函数合成最简单的乘积表达式总和。基本上,如果 AB == CD,则函数为 1,否则为 0,结果如下: (!A && !B && !C && !D) || (!A && B &&
我正在尝试确定是否可以在不溢出的情况下计算两个 32 位整数的总和,同时仅使用某些按位运算符和其他运算符。因此,如果整数 x 和 y 可以相加而不会溢出,则以下代码应返回 1,否则返回 0。 ((((
处理乍一看需要许多嵌套 if 语句的复杂业务逻辑的好方法是什么? 例子: 折扣券。可能: 1a) 超值折扣 1b) 百分比折扣 2a) 正常折扣 2b) 累进折扣 3a) 需要访问优惠券 3b) 不需
假设我有一个“numbers”对象数组,其中包含“startNo”整数和“endNo”整数。 数组中可以有多个“数字”,我想获取一个包含修改对象的新数组,该数组仅具有不重叠的范围。 例如:如果数组有:
我在这个问题上遇到了困难。我正在使用 JavaScript。 我有一个文本区域,用于检测 @ 输入并将其位置存储在数组中。 var input = "@a @b @c" //textarea var
默认 IN 使用 OR 基本逻辑。有没有办法在范围内使用 AND 基本逻辑。 例如下面的查询 SELECT ItemId,CategoryID FROM ItemCategories WHERE Ca
我想在您将鼠标悬停在网站图像上时添加叠加层。我在这里实现了这个,它工作正常http://jsfiddle.net/stujLbjh/ 这是js代码: var divs = document.query
这个问题在这里已经有了答案: Which is faster: x>2 是否比 x>>31 快?换句话说,sar x, 2 是否比 sar x, 31 快?我做了一些简单的测试,他们似乎有相同的速度
我有grails criteriaQuery,我在这里再次检查OR逻辑,就像这样一个状态变量: or { eq("status", Status.ONE) eq("status",
我有grails criteriaQuery,我在这里再次检查OR逻辑,就像这样一个状态变量: or { eq("status", Status.ONE) eq("status",
我是一名优秀的程序员,十分优秀!