code: func (s *Engine) LoadDirectory(dir string, extension string) error {
  
  	var templateErr error
  	s.Templates = template.New(dir)
  	s.Templates.Delims(s.Config.Left, s.Config.Right)
  
  	filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
  		if info == nil || info.IsDir() {
  
  		} else {
  
  			rel, err := filepath.Rel(dir, path)
  			if err != nil {
  				templateErr = err
  				return err
  			}
  
  			ext := filepath.Ext(path)
  			if ext == extension {
  
  				buf, err := ioutil.ReadFile(path)
  				if err != nil {
  					templateErr = err
  					return err
  				}
  
  				contents := string(buf)
  
  				if err == nil {
  
  					name := filepath.ToSlash(rel)
  					tmpl := s.Templates.New(name)
  
  					if s.Middleware != nil {
  						contents, err = s.Middleware(name, contents)
  					}
  					if err != nil {
  						templateErr = err
  						return err
  					}
  					s.mu.Lock()
  					// Add our funcmaps.
  					if s.Config.Funcs != nil {
  						tmpl.Funcs(s.Config.Funcs)
  					}
  
  					tmpl.Funcs(emptyFuncs).Parse(contents)
  					s.mu.Unlock()
  				}
  			}
  
  		}
  		return nil
  	})
  
  	return templateErr
  }
docs: // LoadDirectory builds the templates