LoadString caches (if not already) the specified inline string as a single template and returns a ready to use Renderer instance.
(text string)
| 100 | // LoadString caches (if not already) the specified inline string as a |
| 101 | // single template and returns a ready to use Renderer instance. |
| 102 | func (r *Registry) LoadString(text string) *Renderer { |
| 103 | found := r.cache.Get(text) |
| 104 | |
| 105 | if found == nil { |
| 106 | // parse and cache (using the text as key) |
| 107 | tpl, err := template.New("").Funcs(r.funcs).Parse(text) |
| 108 | found = &Renderer{template: tpl, parseError: err} |
| 109 | r.cache.Set(text, found) |
| 110 | } |
| 111 | |
| 112 | return found |
| 113 | } |
| 114 | |
| 115 | // LoadFS caches (if not already) the specified fs and globPatterns |
| 116 | // pair as single template and returns a ready to use Renderer instance. |