func (d *Dir) Update(force bool) (err error) {
	if force {
		if err = d.Read(); err != nil {
			return
		}
	}
	// remove deleted templates
	for name := range d.Templates {
		found := false
		for _, file := range d.Files {
			if file.Name == name {
				found = true
				break
			}
		}
		if !found {
			delete(d.Templates, name)
		}
	}
	for _, file := range d.Files {
		name := file.Name
		next, ok := d.Templates[name]
		if ok {
			err = next.Update()
		} else {
			println(file.Path())
			next, err = NewTemplate(file.Path())
		}
		if err != nil {
			if err != ErrUnsupportedTemplate {
				return
			}
			log.Warnf("Failed to update template %q, reason: %s\n", name, err)
			continue
		}
		d.Templates[name] = next
	}
	return
}
// Update rereads the entire Dir from disk
Update rereads the entire Dir from disk
// Update rereads the entire Dir from disk
func (d *Dir) Update(force bool) (err error) {
	if force {
		if err = d.Read(); err != nil {
			return
		}
	}
	for name := range d.Templates {
		found := false
		for _, file := range d.Files {
			if file.Name == name {
				found = true
				break
			}
		}
		if !found {
			delete(d.Templates, name)
		}
	}
	for _, file := range d.Files {
		name := file.Name
		next, ok := d.Templates[name]
		if ok {
			err = next.Update()
		} else {
			println(file.Path())
			next, err = NewTemplate(file.Path())
		}
		if err != nil {
			if err != ErrUnsupportedTemplate {
				return
			}
			log.Warnf("Failed to update template %q, reason: %s\n", name, err)
			continue
		}
		d.Templates[name] = next
	}
	return
}
func ( d * Dir ) Update ( force bool ) ( err error ) { if force { if err = d . Read ( ) ; err != nil { return } } for name := range d . Templates { found := false for _ , file := range d . Files { if file . Name == name { found = true break } } if ! found { delete ( d . Templates , name ) } } for _ , file := range d . Files { name := file . Name next , ok := d . Templates [ name ] if ok { err = next . Update ( ) } else { println ( file . Path ( ) ) next , err = NewTemplate ( file . Path ( ) ) } if err != nil { if err != ErrUnsupportedTemplate { return } log . Warnf ( " \n " , name , err ) continue } d . Templates [ name ] = next } return }
Update rereads the entire Dir from disk
Update rereads the entire Dir from disk
// remove deleted templates