code: func NewTemplateResource(path string, config Config) (*TemplateResource, error) {
  	if config.StoreClient == nil {
  		return nil, errors.New("A valid StoreClient is required.")
  	}
  
  	// Set the default uid and gid so we can determine if it was
  	// unset from configuration.
  	tc := &TemplateResourceConfig{TemplateResource{Uid: -1, Gid: -1}}
  
  	log.Debug("Loading template resource from " + path)
  	_, err := toml.DecodeFile(path, &tc)
  	if err != nil {
  		return nil, fmt.Errorf("Cannot process template resource %s - %s", path, err.Error())
  	}
  
  	tr := tc.TemplateResource
  	tr.keepStageFile = config.KeepStageFile
  	tr.noop = config.Noop
  	tr.storeClient = config.StoreClient
  	tr.funcMap = newFuncMap()
  	tr.store = memkv.New()
  	tr.syncOnly = config.SyncOnly
  	addFuncs(tr.funcMap, tr.store.FuncMap)
  
  	if config.Prefix != "" {
  		tr.Prefix = config.Prefix
  	}
  
  	if !strings.HasPrefix(tr.Prefix, "/") {
  		tr.Prefix = "/" + tr.Prefix
  	}
  
  	if len(config.PGPPrivateKey) > 0 {
  		tr.PGPPrivateKey = config.PGPPrivateKey
  		addCryptFuncs(&tr)
  	}
  
  	if tr.Src == "" {
  		return nil, ErrEmptySrc
  	}
  
  	if tr.Uid == -1 {
  		tr.Uid = os.Geteuid()
  	}
  
  	if tr.Gid == -1 {
  		tr.Gid = os.Getegid()
  	}
  
  	tr.Src = filepath.Join(config.TemplateDir, tr.Src)
  	return &tr, nil
  }
docs: // NewTemplateResource creates a TemplateResource.