helm-docs icon indicating copy to clipboard operation
helm-docs copied to clipboard

Cannot include mustache/handlebar templates in example docs

Open AlanMasciangelo opened this issue 2 years ago • 2 comments

I was unable to find a way to "escape" code examples that contain mustache/handlebar templates that I may want to place in a README. Not surprisingly, it seems helm-docs tries to parse them as a go template. For example


My chart

Find the labelled pod

helper_pod="$(kubectl get pod -l app=my-app --template '{{range .items}}{{.metadata.name}}{{end}}')"    

AlanMasciangelo avatar Sep 07 '22 12:09 AlanMasciangelo

You should be able to escape the {{s:

helper_pod="$(kubectl get pod -l app=my-app --template '{{ `{{range .items}}` }} {{`{{.metadata.name}}`}} {{`{{end}}`}}')"

produces:

helper_pod="$(kubectl get pod -l app=my-app --template '{{range .items}} {{.metadata.name}} {{end}}')"

https://felix.ehrenpfort.de/notes/2022-03-01-escape-curly-braces-in-go-templates/

chgl avatar Oct 12 '22 10:10 chgl

Did it work @AlanMasciangelo ?

Nepo26 avatar Jun 29 '23 11:06 Nepo26