carbon / condition
此软件包提供了一些融合辅助功能,使编写条件(`@if`)更简单。
2.0.0
2022-03-29 07:49 UTC
Requires
- neos/neos: ~5.3 || ~7.0 || ~8.0
README
Carbon.Condition 软件包用于 Neos CMS
此软件包提供了一些融合辅助功能,使编写条件(@if
)更简单。
您可以在这里查看一个真实世界的示例
安装
Carbon.Condition
通过 packagist 提供。将 "carbon/condition" : "^2.0"
添加到 composer.json 的 require 部分,或运行 composer require carbon/condition
。
Carbon.Condition:Case
链接到融合文件
如果内容元素或节点类型定义位于文档中,则返回 true。
示例用法
value = 'FooBar' value.@if.render = Carbon.Condition:Case { content { nodeType = 'Foo.Bar:NodeType' propertyFilter = '[row != "one"]' } }
在上面的示例中,如果当前文档中存在节点类型 Foo.Bar:NodeType
且属性 row
设置为非 one
,则仅渲染值 FooBar
。
value = 'FooBar' value.@if.render = Carbon.Condition:Case { document.nodeType = 'Foo.Bar:MixinNodeType' }
在上面的示例中,如果文档包含 mixin Foo.Bar:MixinNodeType
,则仅渲染值 FooBar
。
您也可以混合条件
value = 'FooBar' value.@if.render = Carbon.Condition:Case { content { nodeType = 'Foo.Bar:MixinLightbox' propertyFilter = '[lightbox=true]' } document { nodeType = 'Foo.Bar:MixinLightbox' propertyFilter = '[lightbox=true]' } }
在上面的示例中,如果文档或内容元素包含 mixin Foo.Bar:MixinLightbox
且属性 lightbox
设置为 true
,则仅渲染值 FooBar
。
默认值
node = ${documentNode} enabled = true content { collection = '[instanceof Neos.Neos:ContentCollection]' nodeType = null propertyFilter = '' filter = ${this.nodeType ? ('[instanceof ' + this.nodeType + ']' + this.propertyFilter) : null} } document { nodeType = null propertyFilter = '' filter = ${this.nodeType ? ('[instanceof ' + this.nodeType + ']' + this.propertyFilter) : null} } context { backend = true live = false }
属性概览
Carbon.Condition:Properties
链接到融合文件
检查元素是否应该被渲染的辅助工具。示例用法
@if.render = Carbon.Condition:Properties { properties = 'title,image' }
在上面的示例中,只有当节点具有 title
和 image
设置时,条件才返回 true
。
默认值
node = ${node} properties = null operator = 'AND' context { backend = true live = false }