mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-05-05 20:16:12 +02:00
page.go: report error in template override failure
Raise an error when users specify a template in frontmatter which cannot be resolved.
This commit is contained in:
parent
509ae0c75a
commit
74527d0282
6
page.go
6
page.go
|
@ -199,6 +199,9 @@ func (p *Page) process(cfg *Site, task *Task) error {
|
|||
tmplName = "index"
|
||||
}
|
||||
tmpl, ok := cfg.templates.FindTemplate(p.FilePath, tmplName+task.TemplateExt)
|
||||
if !ok && p.Template != "" {
|
||||
return fmt.Errorf("failed to generate index page %q: template %q specified in frontmatter but not found", p.Path, tmplName)
|
||||
}
|
||||
if ok {
|
||||
var b strings.Builder
|
||||
if err := tmpl.Execute(&b, p); err != nil {
|
||||
|
@ -216,6 +219,9 @@ func (p *Page) process(cfg *Site, task *Task) error {
|
|||
}
|
||||
var b strings.Builder
|
||||
tmpl, ok := cfg.templates.FindTemplate(p.FilePath, tmplName+task.TemplateExt)
|
||||
if !ok && p.Pages[i].Template != "" {
|
||||
return fmt.Errorf("failed to generate page %q: template %q specified in frontmatter but not found", p.Pages[i].Path, tmplName)
|
||||
}
|
||||
if ok {
|
||||
if err := tmpl.Execute(&b, p.Pages[i]); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue