You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
610 B

package chain
import (
"context"
"errors"
"fmt"
"gitoa.ru/go-4devs/templating/loader"
"gitoa.ru/go-4devs/templating/render"
)
var _ loader.Loader = (Loaders)(nil)
type Loaders []loader.Loader
func (l Loaders) Load(ctx context.Context, template render.Reference) (loader.Source, error) {
for idx, load := range l {
sourse, err := load.Load(ctx, template)
if err == nil {
return sourse, nil
}
if !errors.Is(err, loader.ErrNotFound) {
return loader.Source{}, fmt.Errorf("chain[%d]:%w", idx, err)
}
}
return loader.Source{}, fmt.Errorf("chains(%d):%w", len(l), loader.ErrNotFound)
}