GrafoscopioUtils/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st

60 lines
1.6 KiB
Smalltalk
Raw Normal View History

Extension { #name : #LeTextualSnippet }
{ #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> asMarkdeep [
"Inspired by Alpine.js and Assembler CSS 'x-' properties, we are going to use
'st-' properties as a way to extend divs metadata regarding its contents."
| output |
output := '' writeStream.
output
nextPutAll: '<div st-class="', self class asString, '"'; lf;
nextPutAll: ' st-data="', (STON toString: self metadata), '">'; lf;
nextPutAll: self markdeepCustomOpener;
nextPutAll: self contentAsString; lf;
nextPutAll: self markdeepCustomCloser;
nextPutAll: '</div>'; lf; lf.
^ output contents
]
{ #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> childrenIds [
^ self children collect: [ :each | each uidString ]
]
{ #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> markdeepCustomCloser [
^ ''
]
{ #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> markdeepCustomOpener [
^ ''
]
2022-02-11 21:41:25 +00:00
{ #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> metadata [
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ]
]
{ #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> metadataInit [
| surrogate |
self parent
ifNil: [ surrogate := nil]
ifNotNil: [ surrogate := self parent uidString ].
^ OrderedDictionary new
at: 'id' put: self uidString;
at: 'parent' put: surrogate;
at: 'created' put: self createTime asString;
at: 'modified' put: self latestEditTime asString;
at: 'creator' put: self createEmail asString;
at: 'modifier' put: self editEmail asString;
yourself
]
2022-02-11 21:16:32 +00:00
{ #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> options [
2022-02-11 21:41:25 +00:00
^ options
2022-02-11 21:16:32 +00:00
]