--- a/templates/README.md Sun May 07 21:53:13 2017 +0200
+++ b/templates/README.md Sun May 07 21:54:24 2017 +0200
@@ -1,4 +1,4 @@
-# Templates and Themes
+# Themes and Templates
This folder contains sample templates to customize madonctl output.
@@ -18,12 +18,6 @@
the directory is the name of the theme).\
E.g. `$template_directory/themes/ansi/`
-## Templates
-
-Here's an example using a template with ANSI color escape codes (for UNIX/Linux):
-
- madonctl timeline --limit 2 --template-file ansi-status.tmpl
-
## Themes
To use a theme, simply specify the theme name with the --theme flag (the
@@ -37,3 +31,31 @@
Currently, if a template is missing, madonctl will fall back to the _plain_
output format. (In the future it might just fail with an error message.)
+
+## Templates
+
+Here's an example using a template with ANSI color escape codes (for UNIX/Linux):
+
+ madonctl timeline --limit 2 --template-file ansi-status.tmpl
+
+### Template development
+
+Here's a list of available commands (please check the Go template documentation for the built-in functions):
+- fromunix UNIXTIMESTAMP
+- fromhtml HTMLTEXT
+- wrap TEXT
+- trim TEXT
+- color COLORSPEC
+ COLORSPEC is a string with the following format: `[FGCOLOR][,BGCOLOR[,STYLE]]` or `reset`.
+
+ Examples:
+
+ {{color "red"}}red text{{color "reset"}}
+ {{color ",red"}}red background{{color "reset"}}
+ {{color "white,,bold"}}bright white text{{color "reset"}}
+
+ Message: {{color "blue"}}{{.content | fromhtml | wrap " " 80 | trim}}{{color "reset"}}
+
+Note that the _wrap_ implementation might change in the future; currently it is
+paragraph-based, not line-based, and the result can be surprising after
+_fromhtml_ (carriage returns are ignored).