-
Notifications
You must be signed in to change notification settings - Fork 24
Improve templating #96
Conversation
ed1b615
to
4c1f4ed
Compare
main.go
Outdated
@@ -19,6 +19,7 @@ import ( | |||
"bufio" | |||
"flag" | |||
"fmt" | |||
"html/template" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to make this html/template
instead of text/template
? html/template
will escape HTML characters, which is likely undesired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Nice catch. Fixed.
Have you considered using an option to write to a JSON file with all this information and then the caller can programmatically parse the JSON file rather than pass in a template and then parse the output text of retrodep? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 once the comments are considered
Previously the template string was being compiled every time it was used. Instead, compile it only once at the start, then use the compiled template each time it is needed. Signed-off-by: Tim Waugh <[email protected]>
Signed-off-by: Tim Waugh <[email protected]>
That's a good idea. In fact we could have a
This new |
I've updated it to use |
Looks good. Great idea of having more than one output format with |
This commit adds a command line argument -o to control output format. The only defined format is go-template=... which does not add the package name by default, unlike the now-deprecated -template argument which always starts with the package name. Signed-off-by: Tim Waugh <[email protected]>
Signed-off-by: Tim Waugh <[email protected]>
Updated README.md. |
README.md
Outdated
-importpath string | ||
top-level import path | ||
top-level import path | ||
-new-template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reflect argument changes to -o [go-template=...]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
The output template can now be more flexible, so that: