go-templates

How to extend a template in go?

不打扰是莪最后的温柔 提交于 2020-12-07 04:53:48
问题 Here is the problem: There are several article s on each page's content section and I'd like to insert a likebar template below each article. So the base.tmpl is like: <html> <head> {{template "head.tmpl" .}} </head> <body> {{template "content.tmpl" .}} </body> </html> and in article.tmpl I want to have : {{define "content"}} <div>article 1 {{template "likebar.tmpl" .}} </div> <div>article 2 {{template "likebar.tmpl" .}} </div> ... //these divs are generated dynamically {{end}} How can I

How to extend a template in go?

巧了我就是萌 提交于 2020-12-07 04:51:08
问题 Here is the problem: There are several article s on each page's content section and I'd like to insert a likebar template below each article. So the base.tmpl is like: <html> <head> {{template "head.tmpl" .}} </head> <body> {{template "content.tmpl" .}} </body> </html> and in article.tmpl I want to have : {{define "content"}} <div>article 1 {{template "likebar.tmpl" .}} </div> <div>article 2 {{template "likebar.tmpl" .}} </div> ... //these divs are generated dynamically {{end}} How can I

How to extend a template in go?

。_饼干妹妹 提交于 2020-12-07 04:49:31
问题 Here is the problem: There are several article s on each page's content section and I'd like to insert a likebar template below each article. So the base.tmpl is like: <html> <head> {{template "head.tmpl" .}} </head> <body> {{template "content.tmpl" .}} </body> </html> and in article.tmpl I want to have : {{define "content"}} <div>article 1 {{template "likebar.tmpl" .}} </div> <div>article 2 {{template "likebar.tmpl" .}} </div> ... //these divs are generated dynamically {{end}} How can I

Convert a YAML to string in Helm

╄→гoц情女王★ 提交于 2020-06-29 04:13:10
问题 The bounty expires in 11 hours . Answers to this question are eligible for a +100 reputation bounty. Guillaume is looking for an answer from a reputable source : Be able to use YAML and not string in values and use tpl to replace variables in the ConfigMap I have an helm chart used to deploy an application that have configuration file in YAML format. Currently, my helm chart use the following code: values.yaml databaseUser: "dbuser" configFiles: db_config_file.yaml: |- databaseUser: {{

Convert a YAML to string in Helm

霸气de小男生 提交于 2020-06-29 04:13:08
问题 The bounty expires in 11 hours . Answers to this question are eligible for a +100 reputation bounty. Guillaume is looking for an answer from a reputable source : Be able to use YAML and not string in values and use tpl to replace variables in the ConfigMap I have an helm chart used to deploy an application that have configuration file in YAML format. Currently, my helm chart use the following code: values.yaml databaseUser: "dbuser" configFiles: db_config_file.yaml: |- databaseUser: {{

How to parse multiple strings into a template with Go?

ε祈祈猫儿з 提交于 2020-06-26 04:00:10
问题 Is there a simple way like template.ParseFiles("base.html", "home.html") but for strings to build a template from a set of strings? I have a base template and a list of pages templates (all as strings) that I want to build on top of base template. I figured out how to merge them, but I my solution is quite verbose and doesn't look elegant enough, even though working. 回答1: You may create a new, empty template using template.New() function . Then you may use the Template.New() method to create

How to set environment related values.yaml in Helm subcharts?

六月ゝ 毕业季﹏ 提交于 2020-06-24 14:17:10
问题 I am currently deploying my applications in a Kubernetes cluster using Helm. Now I also need to be able to modify some parameter in the values.yaml file for different environments. For simple charts with only one level this is easy by having different values-local.yaml and values-prod.yaml and add this to the helm install flag, e.g. helm install --values values-local.yaml . But if I have a second layer of subcharts, which also need to distinguish the values between multiple environments, I