(ref string, cache *Cache)
| 32 | } |
| 33 | |
| 34 | func ResolveRef(ref string, cache *Cache) any { |
| 35 | // If there is already an error, do nothing |
| 36 | if cache.err != nil { |
| 37 | return nil |
| 38 | } |
| 39 | |
| 40 | // Initialize the cache map if it's not already initialized |
| 41 | if cache.cacheMap == nil { |
| 42 | cache.cacheMap = cache.Vars.ToCacheMap() |
| 43 | } |
| 44 | |
| 45 | if ref == "." { |
| 46 | return cache.cacheMap |
| 47 | } |
| 48 | t, err := template.New("resolver").Funcs(templateFuncs).Parse(fmt.Sprintf("{{%s}}", ref)) |
| 49 | if err != nil { |
| 50 | cache.err = err |
| 51 | return nil |
| 52 | } |
| 53 | val, err := t.Resolve(cache.cacheMap) |
| 54 | if err != nil { |
| 55 | cache.err = err |
| 56 | return nil |
| 57 | } |
| 58 | return val |
| 59 | } |
| 60 | |
| 61 | func Replace[T any](v T, cache *Cache) T { |
| 62 | return ReplaceWithExtra(v, cache, nil) |
no test coverage detected
searching dependent graphs…