gen icon indicating copy to clipboard operation
gen copied to clipboard

{{.name}} Template Variable

Open derekdowling opened this issue 10 years ago • 1 comments

Hello, I am trying to get up to speed on implementing a TypeWriter based on the Set example. How do you feel about adding a "{{.name}}" template variable which is just the lowercased version of "{{.Name}". Perhaps this is simply a templating problem and there is a way I can do this myself? This is useful for things like:

{{.name}} := &{{.Name}}{}

Alternatively, I could achieve this if there was some sort of function that allows us to inject our own template helpers from the most basic information you provide us such as Pointer, Name, and any other arguments I might be missing. Is there currently a way to do any of these things?

derekdowling avatar Jan 17 '16 21:01 derekdowling

Here is the method to inject your proper helper functions Here is the golang template documentation on custom function And here a good example on how to inject a custom type Read the source Luke ;-)

WnP avatar Apr 10 '16 23:04 WnP