codeq/fusionprototypegenerator

有偏见的融合原型生成器

v1.0.1 2018-06-24 16:56 UTC

This package is auto-updated.

Last update: 2024-09-08 06:47:38 UTC


README

默认的Neos DefaultPrototypeGenerator为给定的节点类型生成一个融合原型定义。节点将默认通过Neos.Neos:Content渲染,使用资源://PACKAGE_KEY/Private/Templates/NodeTypes/NAME.html中的模板,并将所有公共节点属性转发到模板融合对象。

这个改进的生成器使用CodeQ.SimpleTemplate根据当前Neos最佳实践映射模板文件路径。

此外,这个融合原型生成器自动创建可编辑属性。propertyName将包含原始属性,而propertyNameEditable包含包装在Neos可编辑对象中的相同属性。

要激活这些生成器,请将您的基节点类型继承自本包提供的混合,例如。

# All nodetypes that want to use new generators should inherit from these ones instead of "Neos.Neos:Content" and "Neos.Neos:Document"
'CodeQ.Site:Content':
  abstract: true
  superTypes:
    'Neos.Neos:Content': true
    'CodeQ.FusionPrototypeGenerator:ContentPrototypeGeneratorMixin': true

'CodeQ.Site:Document':
  abstract: true
  superTypes:
    'Neos.Neos:Document': true
    'CodeQ.FusionPrototypeGenerator:DocumentPrototypeGeneratorMixin': true

示例

假设您有一个内容节点类型用于显示标题

'CodeQ.Site:Content.Headline':
  ...
  properties:
    title:
      type: string
      ui:
        inlineEditable: true
        aloha:
          placeholder: 'Enter headline here...'

生成器将自动动态生成以下类似的融合原型

prototype(CodeQ.Site:Content.Headline) < prototype(CodeQ.SimpleTemplate:Template) {
	title = ${q(node).property("title")}
	title.@process.convertUris = ConvertUris

	titleEditable = Neos.Fusion:Tag {
		content = ${q(node).property("title")}
		content.@process.convertUris = ConvertUris
		@process.contentElementEditable = ContentElementEditable {
			property = "title"
		}
	}
}

现在创建一个内联可编辑的Fluid模板 Resources/Private/Fusion/Content/Headline/Headline.html,其中包含内容

<div class="headline">
	{titleEditable -> f:format.raw()}
</div>