*/
+// Export it so we can populate Hugo's func map with it, which makes it faster.
+var GoFuncs = funcMap
+
// Prepare returns a template ready for execution.
func (t *Template) Prepare() (*template.Template, error) {
if err := t.escape(); err != nil {
*/
+// Export it so we can populate Hugo's func map with it, which makes it faster.
+var GoFuncs = builtinFuncs
+
// Preparer prepares the template before execution.
type Preparer interface {
Prepare() (*Template, error)
funcsv := make(map[string]reflect.Value)
for k, v := range funcs {
- funcsv[k] = reflect.ValueOf(v)
+ vv := reflect.ValueOf(v)
+ funcsv[k] = vv
+ }
+
+ // Duplicate Go's internal funcs here for faster lookups.
+ for k, v := range template.GoFuncs {
+ if _, exists := funcsv[k]; !exists {
+ vv, ok := v.(reflect.Value)
+ if !ok {
+ vv = reflect.ValueOf(v)
+ }
+ funcsv[k] = vv
+ }
+ }
+
+ for k, v := range texttemplate.GoFuncs {
+ if _, exists := funcsv[k]; !exists {
+ funcsv[k] = v
+ }
}
exeHelper := &templateExecHelper{