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 would like to extend Go templates to allow funcs to accept a region as an argument.
This is useful any time you want to process or transform a section of text.
For example, I would like to write a func that performs syntax highlighting
(server-side, while all existing solutions are in javascript):
{{/* A sample template */}}
...
A description of my ExampleFunc function and an example of its usage:
{{prettify "go"}}
func ExampleFunc() {
...
}
{{end}}
For that, I would like to use a template func with a signature like:
"prettify": func(lang, body string) template.HTML
The value of the parameter is the region, already executed. This is necessary to allow
usage of template functionality within the region:
{{prettify "go"}}
{{range .examples}}
func Example1() {
{{.}}
}
{{end}}
{{end}}
The func may be called using the current convention, e.g. {{prettify "go"
"func x()"}}, but the template system allows any func with a final argument of
type "string" to use the region form.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: