Last active
March 30, 2016 12:02
-
-
Save dimaip/d466dfb93c8914a83abd1136ee745bf6 to your computer and use it in GitHub Desktop.
Declarativish TypoScript2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Data in content repository would look like this: | |
{ | |
nodeType: "My:Page", | |
properties: { | |
title: "hello world title" | |
}, | |
children: [ | |
{ | |
nodeType: "My:Text" | |
properties: { | |
text: "Some humble text here" | |
} | |
} | |
] | |
} | |
======================================================= | |
# This object would choose template based on given nodetype | |
prototype(My:ContentCase) < prototype(TYPO3.TypoScript:Case) { | |
default { | |
condition = TRUE | |
type = ${q(node).property('_nodeType.name')} | |
} | |
} | |
# This object would fetch all children of given node and render each of them with according to its nodetype | |
prototype(My:ContentCollectionRenderer) < prototype(TYPO3.TypoScript:Collection) { | |
collection = ${q(node).children()} | |
itemRenderer = My:ContentCase | |
itemName = 'node' | |
} | |
# Object that would render text node, wrapping it in simple tag | |
prototype(My:Text) < prototype(TYPO3.TypoScript:Tag) { | |
tagName = 'p' | |
attributes.class = 'Text' | |
content = ${node.text} | |
} | |
# Root object that starts rendering | |
root = My:ContentCase | |
# Object that renders page nodes | |
prototype(My:Page) < prototype(TYPO3.TypoScript:Array) { | |
# Just take all of its child nodes and render them | |
mainContent = My:ContentCollectionRenderer | |
# Override renderer for nodetype Text in context of My:Page. On other pages it would renderer as is | |
prototype(My:Text) { | |
class = 'Text Text--withinMyPage' | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment