This commit is contained in:
Offray Vladimir Luna Cárdenas 2020-07-27 21:12:00 -05:00
commit e759f93afb

View File

@ -8,7 +8,8 @@ Class {
'shortName',
'template',
'templateData',
'namespace'
'namespace',
'bodyTag'
],
#category : #Brea
}
@ -22,14 +23,40 @@ BreaWikiPage >> bodyContentsAsHTML [
^ Pandoc markdownToHtml: sourcePage
]
{ #category : #accessing }
BreaWikiPage >> bodyTag [
^ bodyTag
]
{ #category : #accessing }
BreaWikiPage >> bodyTag: aString [
"I represent the Mustache Template tag used to denote the body part of a page.
While the metadata is self describing via YAML metadata blocks in Markddown, so
they map where ever they are needed in a template, the Markdown file that will be converted
in HTML via a template doesn't know which part should occupy once the conversion is done.
I provide such knowledge. So if a page template puts the body content under the mustache tag
{{content}}, I should use bodyTag: 'content'.
bodyTag: is template dependant."
bodyTag := aString
]
{ #category : #'as yet unclassified' }
BreaWikiPage >> exportAsHTML [
| htmlContents templateFile |
| htmlContents allActions semaphore result |
self shortName ifNil: [ ^ self ].
self template ifNil: [ ^ self ].
templateFile := self namespace / self template.
htmlContents := (MustacheTemplate on: templateFile contents) value: self templateData.
"htmlContents."
self bodyTag ifNil: [ ^ self ].
allActions := TKTFuture all: {
[ self populateMetadata ] future.
[ self populateBodyAs: self bodyTag ] future.
}.
semaphore := Semaphore new.
allActions onSuccessDo: [ :values |
result := values last.
semaphore signal.
].
semaphore wait.
htmlContents := (MustacheTemplate on: result templateFile contents) value: result templateData.
^ MarkupFile exportAsFileOn: self namespace / (self shortName, '.html' ) containing: htmlContents
]