These are chat archives for gin-gonic/gin

24th
Aug 2017
ankitm123
@ankitm123
Aug 24 2017 12:01
I am trying to display new lines in gin, but that does not seem to work, for instance my variable .log has some text like this "First line \n Second line ", instead of showing first line in one line and second line in the next, it just shows both of them in the same, I tried replacing the \n with <br />, but no luck, any idea how to format the text properly?
Mark Richman
@mrichman
Aug 24 2017 12:02
@ankitm123 when you say "display new lines in gin" do you mean in the log file or in HTML? Please show code examples.
ankitm123
@ankitm123
Aug 24 2017 12:03
HTML
<div class="pre-scrollable" id="logs">
         {{.log}}
</div>
Mark Richman
@mrichman
Aug 24 2017 12:04
wrap that in a <pre> tag and see what happens
This isn't actually a Gin issue. I think it's just how Go templates work. Try asking in the gophers slack channel or on Stack Overflow. Similar question here: https://stackoverflow.com/questions/13779027/html-templates-replacing-newlines-with-br
ankitm123
@ankitm123
Aug 24 2017 12:08
Thanks, this seems to work, I used the pre-tag
Mark Richman
@mrichman
Aug 24 2017 12:17
Great! Happy to help.
fangtao
@azurefang
Aug 24 2017 17:39
Hello, does anyone know if gin support custom context?
johanhess1
@johanhess1
Aug 24 2017 18:14
Anyone?
I'm looking to have an url like this http://www.page.com/pages/NAMESPACE:PageName
But using : for defining the query string makes it hard. Any ideas here?
johanhess1
@johanhess1
Aug 24 2017 18:26
johanhess1
@johanhess1
Aug 24 2017 18:43
But this: router.GET(/pages/:name_space::page_name, handlerFunc)
Doesn't work. Why not, really?