-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed as duplicate of#33273
Closed as duplicate of#33273
Copy link
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.Thinking
Milestone
Description
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.Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.Thinking