定制快递把手如果帮手(Custom Express Handlebars If Helper)
我使用
express-handlebars
遍历一个数组对象,并且每创建一个dom元素都应该有一个特定的属性。像这样的东西:
<div class=""></div> <div></div> <div class=""></div> <div></div>
我注意到有一个包含迭代索引的
@size
值。我的代码到目前为止是这样的:
{{#each todoGroups}} {{#if @index}} <div class=""></div> {{/if}} {{/each}}
但是,如何向if语句添加一个条件,该语句只对每个第二项都计算为
true
?我被困在试图实现这个功能,这是迄今为止我的方法:
function hbsHelpers(hbs) { return hbs.create({ helpers: { // This was missing isEven: function(value, options) { }, // More helpers... }, }); }
I'm iterating over an array object utilizing
express-handlebars
and only every second dom element which is created should have a specific attribute.Something like this:
<div class=""></div> <div></div> <div class=""></div> <div></div>
I noticed that there is a
@size
value which contains the index of the iteration.My code so far is looking like this:
{{#each todoGroups}} {{#if @index}} <div class=""></div> {{/if}} {{/each}}
But how do I add a condition to the if statement which only evaluates to
true
for every second item?I'm stuck trying to implement this functionality this is my approach so far:
function hbsHelpers(hbs) { return hbs.create({ helpers: { // This was missing isEven: function(value, options) { }, // More helpers... }, }); }
原文:https://stackoverflow.com/questions/45620383
最满意答案
我会选择你的选择1.如果我作为用户想要在游戏项目上工作,我不关心其他两个项目,但游戏需要它,所以包括dll。
如果我想对实用程序类进行更改,那么我会对实用程序项目进行更改。
这就像我自己使用另一方的开源项目一样。 当另一方的lib需要更改时,我会去做它,然后将该项目的最新.dll作为依赖项。
I would go with your option 1. If I as a user want to work on the game project, I do not care about the other two projects, but the game needs it, so include the dll.
If I want to make changes to the utility classes, well I then make changes to the utility project.
It is like me using another party's open source project in my own. When the other party's lib needs changes I go and make it there and then just get the latest .dll for this project as a dependency.
相关问答
更多-
你可以看看夏普的迷你代理服务器 。 它支持HTTP和HTTPS。 You could have a look at the Mini Proxy Server in Sharp. It supports both HTTP and HTTPS.
-
具有出色Java / C#代码的开源项目 - 有什么建议吗?(Open source projects with great Java/C# code - any suggestions? [closed])[2022-03-13]
Scott Hanselman在“The Weekly Source Code”系列中一直在审查应用程序及其各自的源代码。 相当深入和多样化的东西。 Scott Hanselman has been reviewing applications and their respective source code in a series "The Weekly Source Code". Pretty in depth and diverse stuff. -
.NET中用于医疗诊断和数据挖掘的任何开源项目[关闭](any Open source projects in .NET for medical diagnosis & data mining [closed])[2023-07-22]
我不熟悉这样的项目,我怀疑它是否存在(因为它非常具体)。 关于开源Java医疗诊断程序, 这是一个类似的问题(+答案)。 I'm not familiar with such a project and I doubt if it exists (as it is quite specific). Here is a similar question (+ answer) though regarding an open source Java medical diagnosis program. -
我应该如何管理/声明开源C#项目之间的依赖关系?(How should I manage/declare dependencies between open source C# projects?)[2023-10-03]
我会选择你的选择1.如果我作为用户想要在游戏项目上工作,我不关心其他两个项目,但游戏需要它,所以包括dll。 如果我想对实用程序类进行更改,那么我会对实用程序项目进行更改。 这就像我自己使用另一方的开源项目一样。 当另一方的lib需要更改时,我会去做它,然后将该项目的最新.dll作为依赖项。 I would go with your option 1. If I as a user want to work on the game project, I do not care about the other ... -
使用IoC的开源项目(Open source projects using IoC)[2022-01-16]
这里有一个演示应用程序,我用它来演示.NET中DI的各个方面,包括组合根 ,配置上的约定等。 https://github.com/ploeh/Booking 虽然它仍然是演示代码,但是它是有意创建的,并且具有一定的复杂性以展示这些内容。 Here's a demo application I use to demonstrate various aspects of DI in .NET, including Composition Root, Convention over Configuration, ... -
单声道 。 Mono.
-
调查后我发现没有这样的工具。 最后,我实现了一个工具,通过为每种类型设置依赖关系字典(包括类,枚举,方法接口,方法体,属性,类成员,属性等)来实现它。 After investigation I found out that there is not such a tool. In the end I implement a tool that does it by set a dictionary of dependencies for each type(including class, enum, m ...
-
检查DSource中的项目。 另请参阅DLinks页面。 Check the projects in DSource. Give a look also to the DLinks page.
-
试试CMAKE CMake是一个跨平台的开源构建系统。 CMake是一个用于构建,测试和打包软件的工具系列。 CMake用于使用简单的平台和编译器独立配置文件来控制软件编译过程。 CMake生成可在您选择的编译器环境中使用的本地makefile和工作区。 Try CMAKE CMake, is a cross-platform, open-source build system. CMake is a family of tools designed to build, test and package s ...
-
是否有任何开源项目在内部使用linq?(Is there any open source projects that employs linq within? [closed])[2021-11-16]
虽然我还没有检查过,但我认为SubSonic是我的TODO列表中的一个。 我猜它会有很多Linq技术。 Though I have not checked it yet, I think SubSonic is one in my TODO List to study. I assume it will have lot of Linq techniques.