make strings.ReplaceAll available in templates

* replace newline with br in rss template
This commit is contained in:
gutmet 2020-11-25 14:49:49 +01:00
parent 11dd018f97
commit 0687b4e2f2
2 changed files with 3 additions and 2 deletions

View File

@ -583,7 +583,7 @@ func wrapCommandFl(cmd func() (goutil.CommandFlagsInit, goutil.CommandFunc)) fun
flagsInit(s) flagsInit(s)
}, func(args []string) error { }, func(args []string) error {
if f.templateFile != "" { if f.templateFile != "" {
formatTemplate = template.Must(template.ParseFiles(f.templateFile)) formatTemplate = template.Must(template.New(filepath.Base(f.templateFile)).Funcs(template.FuncMap{"replaceAll": strings.ReplaceAll}).ParseFiles(f.templateFile))
} }
return commandFunc(args) return commandFunc(args)
} }

View File

@ -16,7 +16,8 @@
{{end}} {{end}}
{{$user := $status.User.Screen_name}} {{$user := $status.User.Screen_name}}
@{{$user}} ({{$status.Id_str}}){{if $status.In_reply_to_status_id_str}} in reply to {{$status.In_reply_to_screen_name}} ({{$status.In_reply_to_status_id_str}}){{end}}: <br><br>{{$status.Text}} @{{$user}} ({{$status.Id_str}}){{if $status.In_reply_to_status_id_str}} in reply to {{$status.In_reply_to_screen_name}} ({{$status.In_reply_to_status_id_str}}){{end}}: <br><br>
{{replaceAll $status.Text "\n" "<br>"}}
{{range $idxMedia, $media := $status.Extended_entities.Media}} {{range $idxMedia, $media := $status.Extended_entities.Media}}
<br><a href="https://twitter.com/{{$user}}/status/{{$status.Id_str}}"><img src="{{$media.Media_url}}"></a> <br><a href="https://twitter.com/{{$user}}/status/{{$status.Id_str}}"><img src="{{$media.Media_url}}"></a>
{{end}} {{end}}