~srivathsan/blaze

f74b675372e7091d86f3075e90f5c4ccedf9db3d — Srivathsan Murali 3 years ago 6a4cf60
check for empty string in summary and template
1 files changed, 7 insertions(+), 0 deletions(-)

M builder/templates.go
M builder/templates.go => builder/templates.go +7 -0
@@ 56,6 56,9 @@ func getTemplateFuncs(config *config.BlazeConfig) template.FuncMap {
			return html.EscapeString(content)
		},
		"summary": func(content string) string {
			if content == "" {
				return ""
			}
			index := strings.Index(content, "</p>")
			return fmt.Sprintf("%s</p>", content[:index])
		},


@@ 65,6 68,10 @@ func getTemplateFuncs(config *config.BlazeConfig) template.FuncMap {
func ParseTemplateString(
	config *config.BlazeConfig, templateString string,
	data interface{}) (string, error) {
	if templateString == "" {
		return "", nil
	}

	temp, err := template.New("page_content").
		Funcs(getTemplateFuncs(config)).Parse(templateString)
	if err != nil {