1

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?

2
  • Sorry, I'm not quite sure what Revel is. Give a better explanation in what you're trying to achieve and people can help you better. Meanwhile, check out this example to learn how to handle forms in go. It's written for the app engine, but you'll get the idea. developers.google.com/appengine/docs/go/gettingstarted/… Commented Jul 11, 2014 at 7:34
  • Rendering templates in Revel (revel.github.io) is stated in this documentation: revel.github.io/tutorial/requestflow.html#hot-reload And we have the same problem by which the variable passed from the controller can't be received by the templates/views Commented Aug 11, 2014 at 6:19

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.