-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add method HTMLBlob for more streamlined / less allocating renders. #761
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
Add method HTMLBlob for more streamlined / less allocating renders. #761
Conversation
460b525 to
9f034c2
Compare
…sting them to strings, which is a bit unnecessary considering under the hood Echo supports this.
9e9676c to
daed69f
Compare
…sting them to strings, which is a bit unnecessary considering under the hood Echo supports this.
|
@RyanCopley You can use |
|
Ah-- blob is the word I should've looked for. That wouldn't set the content-type, and there is both an |
|
@RyanCopley You can set content type in |
|
Absolutely! |
| func (c *context) HTMLBlob(code int, b []byte) (err error) { | ||
| return c.Blob(code, MIMETextHTMLCharsetUTF8, b) | ||
| } | ||
|
|
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.
You can also modify HTML to use HTMLBlob like in JSON. With that you don't need your test case as it will be already covered - just for consistency.
|
@vishr Done :) |
|
Closed in #765 |
|
Thanks for your contribution 👍 |
Hey echo maintenance! 👋
We're utilizing Echo in a project and I'm trying to clean up some of our project. I noticed that we're converting bytes.Buffer's into strings, then back to a byte array. That seems a little bit much just to move some text around so I thought it'd be nice if there was a method that directly accepts bytes.Buffers (which this package already imports, thankfully!)
Since some templating (I'm looking at you, pongo2) engines final result is a buffer, we've been casting them to strings, which is a bit unnecessary considering under the hood Echo supports this.
Let me know if you have any questions:)