3
0

Little template tweaks

This commit is contained in:
Tomaž Jerman
2021-03-09 15:45:14 +01:00
parent 7b12e6f056
commit c4995dd8eb
2 changed files with 11 additions and 4 deletions

View File

@@ -3,8 +3,10 @@ package service
import (
"bytes"
"context"
"fmt"
"io"
"strconv"
"strings"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/handle"
@@ -99,7 +101,7 @@ func (svc template) FindByHandle(ctx context.Context, h string) (tpl *types.Temp
}
if tpl, err = store.LookupTemplateByHandle(ctx, svc.store, h); err != nil {
return TemplateErrInvalidHandle().Wrap(err)
return TemplateErrNotFound().Wrap(err)
}
tplProps.setTemplate(tpl)
@@ -408,9 +410,14 @@ func (svc template) getPartials(ctx context.Context, tpl *types.Template) ([]*re
// @todo do some filtering based on partial type and main template type
for _, t := range set {
tpl := t.Template
if !strings.HasPrefix(tpl, "{{define") {
tpl = fmt.Sprintf(`{{define "%s"}}%s{{end}}`, t.Handle, tpl)
}
pp = append(pp, &renderer.TemplatePartial{
Handle: t.Handle,
Template: bytes.NewBuffer([]byte(t.Template)),
Template: bytes.NewBuffer([]byte(tpl)),
TemplateType: t.Type,
})
}

View File

@@ -70,8 +70,8 @@ type (
const (
DocumentTypePlain DocumentType = "text/plain"
DocumentTypeHTML = "text/html"
DocumentTypePDF = "application/pdf"
DocumentTypeHTML DocumentType = "text/html"
DocumentTypePDF DocumentType = "application/pdf"
)
func (t *TemplateMeta) Scan(value interface{}) error {