Jade 动态混合调用无法按预期工作
Jade dynamic mixin call not working as expected
目前我有 2 个混入,我正在考虑添加更多。这些 mixin 可能会出现在其他 mixin 中,但也可能不会。
查看 This,我尝试了以下
+#{displayType}(group[fieldName])
但是这似乎无法解析。
我想避免
case displayType
when boolSimpleStatus
+boolSimpleStatus(group[fieldName])
when boolCheckBox
+boolCheckBox(group[fieldName])
我的 mixin 总共是
mixin boolean_table_cell(fieldName, group, displayType)
+data_table_cell(fieldName)
+#{displayType}(group[fieldName])
据我所知,插值适用于传递给已编译模板的参数。在您的情况下, displayType 是 mixin 的一个参数,这就是它不起作用的原因。您可以从 mixin 中删除参数并通过调用渲染函数传递它 res.render(whatevertemplate, {displayType: whatevertype}) 并且插值应该适用于
目前我有 2 个混入,我正在考虑添加更多。这些 mixin 可能会出现在其他 mixin 中,但也可能不会。
查看 This,我尝试了以下
+#{displayType}(group[fieldName])
但是这似乎无法解析。
我想避免
case displayType
when boolSimpleStatus
+boolSimpleStatus(group[fieldName])
when boolCheckBox
+boolCheckBox(group[fieldName])
我的 mixin 总共是
mixin boolean_table_cell(fieldName, group, displayType)
+data_table_cell(fieldName)
+#{displayType}(group[fieldName])
据我所知,插值适用于传递给已编译模板的参数。在您的情况下, displayType 是 mixin 的一个参数,这就是它不起作用的原因。您可以从 mixin 中删除参数并通过调用渲染函数传递它 res.render(whatevertemplate, {displayType: whatevertype}) 并且插值应该适用于