blablacar / dgr

Container build and runtime tool
Apache License 2.0
249 stars 21 forks source link

Templates Function isMap,isInt,isWhatever #154

Closed nyodas closed 8 years ago

nyodas commented 8 years ago

Hi It would be awesome to have a functions capable of returning true or false when the input is tested against a particular type.

ie :

{{ $a := json {"a":{"b":{"c":"d"}}} }}
{{ isMap $a }}
true
{{ $b := "lolilol" }}
{{ isMap $b }}
false
nyodas commented 8 years ago
{{define "config"}}
{{- if . -}}
  {{- range $a,$b := . -}}
    {{$a}}:{{if not (isMap $b)  }}{{ $b }} {{else}} {{template "config" $b }}{{end}}
    {{end}}
  {{end}}
{{- end -}}
{{- end -}}
 config:
    algolia:
      indices:
          places:
              proxy:   ~
              timeout: ~
              appId:   "pompompompom"
              appKey:  "oooooooooooooo"
n0rad commented 8 years ago

done in v65