问题描述
这是一个典型的Handlebars帮助器:
Here's a typical Handlebars helper:
c> dolor 属性将被使用并作为组合字符串返回。Here the values of lorem, ipsum, and dolor properties would be used and returned as a combined string.
除了必需的参数之外,如果你通过在附加参数中,它们将在 options.hash 中可用。这些属性被视为字符串,默认情况下不会被解析。您将需要使用 options.data.view 来首先查找其值。参见这个作为一个例子,如果你需要这样做。
In addition to the required arguments, if you pass in additonal parameters they would be available in options.hash. These properties are treated as strings and aren't resolved by default. You would need to use, options.data.view to lookup their values first. See this answer for an example if you need to do this.
最后 options.data 是提供给帮助者的特殊属性。它是保存变量,上下文等的原始句柄框架。它主要用于块助手。由于块助手不会自己渲染,而是调用其他帮助者, options.data 允许这样的块助手将额外的变量注入到子助手框中。有关详细信息,请参阅文档。
Finally options.data is special property provided to helpers. It's the raw handlebars Frame that holds variables, contexts and so on. It is mostly for use with block helpers. Since block helpers don't do rendering themselves but call other helpers, options.data allows such block helpers to inject additional variables into the child helpers frame. For details see the docs here.
以下是示例。
这篇关于如何传递参数到Handlebars的帮手? options.hash和amp之间有什么区别? options.data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!