Fix in_reply_to ID format in templates
authorMikael Berthe <mikael@lilotux.net>
Sat, 06 May 2017 19:52:39 +0200
changeset 76 f155f9d86832
parent 75 447ac88b67c6
child 77 23b2b6c5643e
Fix in_reply_to ID format in templates The default format for numbers in templates is double, so we have to explicitly set the format string. BTW, replace ".var | printf FMT" with "printf FMT .var"... It is slightly more readable.
templates/ansi-account.tmpl
templates/ansi-notification.tmpl
templates/ansi-status.tmpl
--- a/templates/ansi-account.tmpl	Sat May 06 19:44:48 2017 +0200
+++ b/templates/ansi-account.tmpl	Sat May 06 19:52:39 2017 +0200
@@ -1,4 +1,4 @@
-- Account ID: {{color "red"}}{{.id|printf "%.0f"}}{{color "reset"}}  {{color "magenta"}}@{{.username}}{{color "reset"}}
+- Account ID: {{color "red"}}{{printf "%.0f" .id}}{{color "reset"}}  {{color "magenta"}}@{{.username}}{{color "reset"}}
   UID: {{color "red"}}{{.acct}}{{color "reset"}}
   Display name: {{color "white,,bold"}}{{.display_name}}{{color "reset"}}
   Date: {{.created_at}}
--- a/templates/ansi-notification.tmpl	Sat May 06 19:44:48 2017 +0200
+++ b/templates/ansi-notification.tmpl	Sat May 06 19:52:39 2017 +0200
@@ -1,12 +1,12 @@
-- Notification ID: {{color "red"}}{{.id|printf "%.0f"}}{{color "reset"}}
+- Notification ID: {{color "red"}}{{printf "%.0f" .id}}{{color "reset"}}
   Type: {{color ",,bold"}}{{.type}}{{color "reset"}}
   Timestamp: {{.created_at}}
 {{- with .url}}
       URL: {{.url}}{{end}}
 {{- with .account}}
-  - Account: ({{.id|printf "%.0f"}}) {{color "magenta"}}@{{.acct}}{{color "reset"}}{{if .display_name}} - {{color "white,,bold"}}{{.display_name}}{{color "reset"}}{{end}}{{end}}
+  - Account: ({{printf "%.0f" .id}}) {{color "magenta"}}@{{.acct}}{{color "reset"}}{{if .display_name}} - {{color "white,,bold"}}{{.display_name}}{{color "reset"}}{{end}}{{end}}
 {{- with .status}}
-  - Status ID: {{color "red"}}{{.id|printf "%.0f"}}{{color "reset"}}  {{color "magenta"}}@{{.account.acct}}{{color "reset"}}
+  - Status ID: {{color "red"}}{{printf "%.0f" .id}}{{color "reset"}}  {{color "magenta"}}@{{.account.acct}}{{color "reset"}}
     Name: {{color ",,bold"}}{{.account.display_name}}{{color "reset"}}
     Date: {{.created_at}}
     URL: {{.url}}
@@ -16,13 +16,13 @@
     Spoiler: {{.}}{{end}}
 {{- if .reblog }}{{with .reblog}}
     {{color ",,bold"}}Reblogged from: {{color "magenta"}}@{{.account.acct}}{{color "reset"}}
-      ID: {{.id|printf "%.0f"}}
+      ID: {{printf "%.0f" .id}}
       Name: {{color ",,bold"}}{{.account.display_name}}{{color "reset"}}
       Date: {{.created_at}}
       Message: {{color "blue"}}{{.content | fromhtml}}{{color "reset"}}{{end}}{{else}}
     Message: {{color "blue"}}{{.content | fromhtml}}{{color "reset"}}
 {{- range .media_attachments}}
-    - Attachment ID: {{.id|printf "%.0f"}}
+    - Attachment ID: {{printf "%.0f" .id}}
 {{- if .text_url}}
       Text URL: {{.text_url}}{{else if .url}}
       URL: {{.url}}{{else if .remote_url}}
--- a/templates/ansi-status.tmpl	Sat May 06 19:44:48 2017 +0200
+++ b/templates/ansi-status.tmpl	Sat May 06 19:52:39 2017 +0200
@@ -1,19 +1,19 @@
-- Status ID: {{color "red"}}{{.id|printf "%.0f"}}{{color "reset"}}  {{color "magenta"}}@{{.account.acct}}{{color "reset"}}
+- Status ID: {{color "red"}}{{printf "%.0f" .id}}{{color "reset"}}  {{color "magenta"}}@{{.account.acct}}{{color "reset"}}
   Name: {{color ",,bold"}}{{.account.display_name}}{{color "reset"}}
   Date: {{.created_at}}
   URL: {{.url}}
 {{- if gt .in_reply_to_id 0.0}}
-  Replying to: {{.in_reply_to_id}}{{end}}
+  Replying to: {{printf "%.0f" .in_reply_to_id}}{{end}}
 {{- with .spoiler_text}}
   Spoiler: {{.}}{{end}}
 {{- if .reblog }}{{with .reblog}}
   {{color ",,bold"}}Reblogged from: {{color "magenta"}}@{{.account.acct}}{{color "reset"}}
-    ID: {{.id|printf "%.0f"}}
+    ID: {{printf "%.0f" .id}}
     Name: {{color ",,bold"}}{{.account.display_name}}{{color "reset"}}
     Date: {{.created_at}}
     Message: {{color "blue"}}{{.content | fromhtml}}{{color "reset"}}
 {{- range .media_attachments}}
-    - Attachment ID: {{.id|printf "%.0f"}}
+    - Attachment ID: {{printf "%.0f" .id}}
 {{- if .text_url}}
       Text URL: {{.text_url}}{{else if .url}}
       URL: {{.url}}{{else if .remote_url}}
@@ -21,7 +21,7 @@
 {{end}}{{else}}
   Message: {{color "blue"}}{{.content | fromhtml}}{{color "reset"}}
 {{- range .media_attachments}}
-  - Attachment ID: {{.id|printf "%.0f"}}
+  - Attachment ID: {{printf "%.0f" .id}}
 {{- if .text_url}}
     Text URL: {{.text_url}}{{else if .url}}
     URL: {{.url}}{{else if .remote_url}}