Skip to content
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

| html 怎么用 #37

Open
zhishaofei3 opened this issue Jul 20, 2015 · 0 comments
Open

| html 怎么用 #37

zhishaofei3 opened this issue Jul 20, 2015 · 0 comments

Comments

@zhishaofei3
Copy link

Pipelines

The above transformations insert pieces of text into a template. Those pieces of text are essentially arbitrary, whatever the string values of the fields are. If we want them to appear as part of an HTML document (or other specialised form) then we will have to escape particular sequences of characters. For example, to display arbitrary text in an HTML document we have to change "<" to "<". The Go templates have a number of builtin functions, and one of these is the function html. These functions act in a similar manner to Unix pipelines, reading from standard input and writing to standard output.

To take the value of the current object '.' and apply HTML escapes to it, you write a "pipeline" in the template

{{. | html}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant