[go template] variables传递

281 阅读1分钟

借助Sprig函数库

如何变量设置为map或list

{{- $schemaName := (dict "sn" $schemaName "ctx" .) }}

定义的template如何访问外部的值

  1. 借助$在模板内部访问Values的值
  2. 通过将 . 作为参数传入模板内部

template 传多个参数

{{- include "common.sd.update" (dict "sn" $schemaName "ctx" .) | indent 18 }}