cnaize
cnaize

Reputation: 3149

Golang render string as html in Revel

I need to render string as html in Revel. How to do this? I've tried:

func (c Pages) Show(url string) revel.Result {    
    bigDig := "<h1>Hello, dig!</h1>"

    return c.Render(bigDig)
}

and then in view:

{{template "header.html" .}}

{{.bigDig}}

{{template "footer.html" .}}

but it doesn't work. How to do this?

Upvotes: 1

Views: 4336

Answers (2)

JeffChen
JeffChen

Reputation: 43

You should change your {{.bigDig}} into {{raw .bigDig}}

Upvotes: 2

Cronos87
Cronos87

Reputation: 1926

Your var need to be in a template.HTML type.

Read http://golang.org/pkg/html/template/#HTML or https://groups.google.com/forum/#!topic/golang-nuts/8L4eDkr5Q84.

Upvotes: 2

Related Questions