-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Templates should just be part of the compiled binary, ideally. #20
Comments
…sts. Extract the template text/html into constants. Reference the constants instead of the file read content. Next, remove 'loadTemplate' since it will not be used anylonger.
@morrowc Thank you for your idea and PR! Sorry for late answer. I see that searching templates in current working directory is a bad idea. Your way has many advantages for end user:
And one disadvantage:
Maybe we can keep your changes and add another output format for using external template file? What do you think? Something like this: output:
format: "external_template"
external_template: "/path/to/file.gotmpl" |
howdy! no worries on the delays... I think there are 2 things going on:
You mention: "easier for development", which seems specious to me, since unless you included a ton of random/extra data in the template data struct, you'd always have to reompile to get data included and output that in the template(s) output? |
Yes, I meant this. For me, data struct is almost static and isn't changed a lot. But html or txt templates can be changed a lot during development process or even in production usage. I don't know, maybe someone already uses self-written custom templates. That's why I would like to keep ability to use external template via another output format. Anyway, your PR is good, I'm going to merge it soon. |
ah! ok, I see your usecase now. If you merge this and send me an issue I'll put in a pr that we can discuss? |
This should address #20, move the template content into the compiled binary.
I merged your PR and added external_template output format. Thanks! |
New version v0.6 was released |
Having the templates read at run-time means that the current working directory when launching the binary
must have a `./templates/...' with the appropriate content included. If this isn't the case you get:
$ /usr/local/bin/dmarc-report-converter -config /etc/dmarc-reporting/config.yaml panic: open ./templates/html_static.gotmpl: no such file or directory goroutine 1 [running]: main.loadTemplate(0x8c1c680, 0x1e, 0xc) /usr/local/bin/config.go:63 +0xf6 main.loadConfig(0xbff2ec2a, 0x43, 0x2, 0x3, 0x0) /usr/local/bin/config.go:90 +0x11c main.main() /usr/local/bin/main.go:30 +0x159 $
how about discussion-over-code-review? :)
The text was updated successfully, but these errors were encountered: