You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a struct with string fields that I want outputted in HTML. As they are of type string, they're not showing unescaped so when I do {{ .Post.Title }} in the template I get outputs like: Dan's post!.
I have added <DOCTYPE html> to try and fix it but it doesn't work.
I've found that I should make the fields of type template.HTML, ensuring that it is properly sanitised before outputting. However, I want to store it in a database and when I try, I get the error:
sql: converting Exec argument #0's type: unsupported type template.HTML, a string
Any ideas?
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
sql: converting Exec argument #0's type: unsupported type template.HTML, a string
database/sql: converting Exec argument #0's type: unsupported type template.HTML, a string
Feb 16, 2016
In the IRC I went with the consensus that template.HTML stuff should be isolated in whatever code handles the templating and it shouldn't affect other packages.
So instead of attempting to store template.HTML fields in the database, I stick to storing them as strings and I add a method on the struct that returns the string values as type template.HTML once it has sanitised the string and everything.
I have a struct with string fields that I want outputted in HTML. As they are of type string, they're not showing unescaped so when I do
{{ .Post.Title }}
in the template I get outputs like:Dan's post!
.I have added
<DOCTYPE html>
to try and fix it but it doesn't work.I've found that I should make the fields of type
template.HTML
, ensuring that it is properly sanitised before outputting. However, I want to store it in a database and when I try, I get the error:sql: converting Exec argument #0's type: unsupported type template.HTML, a string
Any ideas?
The text was updated successfully, but these errors were encountered: