diff --git a/repository/Brea/BreaWikiPage.class.st b/repository/Brea/BreaWikiPage.class.st index 94c36ed..a020bd2 100644 --- a/repository/Brea/BreaWikiPage.class.st +++ b/repository/Brea/BreaWikiPage.class.st @@ -9,7 +9,8 @@ Class { 'template', 'templateData', 'namespace', - 'bodyTag' + 'bodyTag', + 'splitters' ], #category : #Brea } @@ -48,6 +49,7 @@ BreaWikiPage >> exportAsHTML [ self bodyTag ifNil: [ ^ self ]. allActions := TKTFuture all: { [ self populateMetadata ] future. + [ self split ] future. [ self populateBodyAs: self bodyTag ] future. }. semaphore := Semaphore new. @@ -120,6 +122,41 @@ BreaWikiPage >> shortName: aString [ shortName := aString ] +{ #category : #'as yet unclassified' } +BreaWikiPage >> split [ + self splitters keysAndValuesDo: [ :key :value | self split: key with: value ]. +] + +{ #category : #'as yet unclassified' } +BreaWikiPage >> split: key with: subkey [ + "I split a comma separated collection of subkeys stored in the 'key' field and name each one as 'subkey' + to put it indiviudally in a Mustache template." + | allSubkeys cleaned data | + allSubkeys := (self populateMetadata at: key) splitOn: ','. + cleaned := allSubkeys collect: [ :item | item withBlanksCondensed ]. + data := OrderedCollection new. + cleaned do: [ :item | + data add: { subkey -> item } asDictionary ]. + self populateMetadata at: key put: data; yourself. +] + +{ #category : #'as yet unclassified' } +BreaWikiPage >> splitterAt: key with: subkey [ + self splitters at: key put: subkey +] + +{ #category : #accessing } +BreaWikiPage >> splitters [ + ^ splitters ifNil: [ splitters := Dictionary new ] +] + +{ #category : #accessing } +BreaWikiPage >> splitters: aDictionary [ + "I model the pattern where a Mustache template contains something like + {{# key}} {{value}} {{/ key}} and has data that needs to be split before injecting it in the template." + splitters := aDictionary +] + { #category : #accessing } BreaWikiPage >> template [ ^ template