ketchup
ketchup copied to clipboard
Any partial/include template example?
Hi Octavore.
Thanks for a great product!
Tell me please, is it possible to do something like this in templates:
<html>
<head>
{{ template "header" . }}
// pr
{{ partial "header". }} <- like hugo do?
</head>
...
header.html:
{{define "header"}}
<meta>
<link rel="stylesheet" ..>
{{end}}
As far as I can see right now, system gives me an error, any ideas how i can do this?
thanks for reply in advance
Thanks for the kind words!
Unfortunately that's not currently possible because the templates are rendered directly from the specified template file without loading other templates, but I do think it's worth supporting. I'll try to put something together :)
Great, thank you. Let's leave this ticket open and add enhancement label?
@vladyslav2 this should be fixed now in 0.2.0, you can refer to other template files with e.g. {{ template "path/to/header.html"
, where path is relative to $THEME_ROOT/templates
. let me know!
@octavore
{{ template "header.html" }}
- works
{{ template "partials/header.html" }}
- do not works, engine still searching for a template in /templates directory
2017/08/21 13:00:26 [ERROR] error serving page /come-on-come-on [b7ad9a6c-9bf8-41ec-8270-4b0a0b6e16a8]: open data/themes/ketchup-docs/templates/header.html: no such file or directory
2017/08/21 13:00:26 [ERROR] [github.com/ketchuphq/ketchup/server/content/templates/filestore/filestore.go:102] open data/themes/ketchup-docs/templates/header.html: no such file or directory
good catch, I've just pushed a fix to master