Skip to content

Commit 3c7782d

Browse files
committed
Fix bug: Template variables must not have spaces so use underscore
1 parent 1981335 commit 3c7782d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,12 @@ func (p *MWXMLCreator) Run() {
523523
wikiText := ""
524524

525525
if p.UseTemplates && len(page.Categories) > 0 { // We need at least one category, as to name the (to-be) template
526+
526527
wikiText += "{{" + page.Categories[0] + "\n" // TODO: What to do when we have multipel categories?
527528

528529
// Add facts as parameters to the template
529530
for _, fact := range page.Facts {
530-
wikiText += "|" + fact.Property + "=" + fact.Value + "\n"
531+
wikiText += "|" + str.Replace(fact.Property, " ", "_", -1) + "=" + fact.Value + "\n"
531532
}
532533

533534
// Add categories as multi-valued call to the "categories" value of the template
@@ -542,6 +543,7 @@ func (p *MWXMLCreator) Run() {
542543

543544
wikiText += "\n}}"
544545
} else {
546+
545547
// Add fact statements
546548
for _, fact := range page.Facts {
547549
wikiText += fmtFact(fact.Property, fact.Value)
@@ -551,6 +553,7 @@ func (p *MWXMLCreator) Run() {
551553
for _, cat := range page.Categories {
552554
wikiText += fmtCategory(cat)
553555
}
556+
554557
}
555558

556559
xmlData := fmt.Sprintf(wikiXmlTpl, page.Title, pageTypeToMWNamespace[page.Type], time.Now().Format("2006-01-02T15:04:05Z"), wikiText)

0 commit comments

Comments
 (0)