# 助手

¥Helpers

# options 参数

¥The options-parameter

除了辅助程序调用中使用的参数之外,还会将 options 对象作为附加参数传递给辅助程序。

¥In addition to the parameters used in the helper-call, an options-object is passed to the helper as additional parameter.

  • lookupProperty(object, propertyName):返回对象的 "自有属性" 的函数。此功能遵循 allowedProtoPropertiesallowedProtoMethods 中指定的白名单。示例:

    ¥lookupProperty(object, propertyName): a function that returns an "own property" of an object. Whitelists specified in allowedProtoProperties and allowedProtoMethods are respected by this function. Example:

    preparationScript
    Handlebars.registerHelper('lookupOrDefault', function (object, propertyName, defaultValue, options) {
        var result = options.lookupProperty(object, propertyName)
        if (result != null) {
            return result
        }
        return defaultValue
    })
    
  • 待办事项:描述传递给助手的所有选项

    ¥TODO: Describe all options that are passed to helpers

Last Updated: 2024/4/16 21:37:19