mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00: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
81e35cb1eb
commit
505244bea2
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 a new issue