Socialmetrica/Socialmetrica.package/NitterUser.class/instance/exportWithTemplate.into..st

29 lines
1.4 KiB
Smalltalk

accessing
exportWithTemplate: mustacheFile into: folder
| tempDictionary bioModified userModified nameModified |
tempDictionary := self asDictionary copy.
(mustacheFile fullName endsWith: '.html')
ifTrue: [ ^ MarkupFile
exportAsFileOn: (folder / self userName , 'html')
containing:(mustacheFile asMustacheTemplate value: tempDictionary)].
(mustacheFile fullName endsWith: '.tex')
ifTrue: [ bioModified := self asDictionary at: 'profile-bio'.
bioModified := bioModified copyReplaceAll: '@' with: '\@'.
bioModified := bioModified copyReplaceAll: '_' with: '\_'.
bioModified := bioModified copyReplaceAll: '#' with: '\#'.
bioModified := bioModified copyReplaceAll: '👑😎' with: ''.
bioModified := bioModified copyReplaceAll: '🇨🇴' with: ''.
bioModified := bioModified copyReplaceAll: '|' with: ''.
userModified := self asDictionary at: 'profile-card-username'.
userModified := userModified copyReplaceAll: '_' with: '\_'.
nameModified := self asDictionary at: 'profile-card-fullname'.
nameModified := nameModified copyReplaceAll: '🇨🇴' with: ''.
tempDictionary at: 'profile-bio' put: bioModified;
at: 'profile-card-username' put: userModified;
at: 'profile-card-fullname' put: nameModified.
^ MarkupFile
exportAsFileOn: (folder / self userName , 'tex')
containing:(mustacheFile asMustacheTemplate value: tempDictionary)]