We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug The name parameter of the template built-in function has a scope problem
view/html.go func (s *HTMLEngine) getBuiltinFuncs(name string) template.FuncMap { funcs := template.FuncMap{ "part": func(partName string, binding interface{}) (template.HTML, error) { nameTemp := strings.ReplaceAll(name, s.extension, "") fullPartName := fmt.Sprintf("%s-%s", nameTemp, partName) result, err := s.executeTemplateBuf(fullPartName, binding) if err != nil { return "", nil } return template.HTML(result), err }, "current": func() (string, error) { return name, nil }, "partial": func(partialName string, binding interface{}) (template.HTML, error) { fullPartialName := fmt.Sprintf("%s-%s", partialName, name) if s.Templates.Lookup(fullPartialName) != nil { result, err := s.executeTemplateBuf(fullPartialName, binding) return template.HTML(result), err } return "", nil }, // partial related to current page, // it would be easier for adding pages' style/script inline // for example when using partial_r '.script' in layout.html // templates/users/index.html would load templates/users/index.script.html "partial_r": func(partialName string, binding interface{}) (template.HTML, error) { ext := filepath.Ext(name) root := name[:len(name)-len(ext)] fullPartialName := fmt.Sprintf("%s%s%s", root, partialName, ext) if s.Templates.Lookup(fullPartialName) != nil { result, err := s.executeTemplateBuf(fullPartialName, binding) return template.HTML(result), err } return "", nil }, "render": func(fullPartialName string, binding interface{}) (template.HTML, error) { result, err := s.executeTemplateBuf(fullPartialName, binding) return template.HTML(result), err }, }
The text was updated successfully, but these errors were encountered:
kataras
No branches or pull requests
Describe the bug
The name parameter of the template built-in function has a scope problem
view/html.go
func (s *HTMLEngine) getBuiltinFuncs(name string) template.FuncMap {
funcs := template.FuncMap{
"part": func(partName string, binding interface{}) (template.HTML, error) {
nameTemp := strings.ReplaceAll(name, s.extension, "")
fullPartName := fmt.Sprintf("%s-%s", nameTemp, partName)
result, err := s.executeTemplateBuf(fullPartName, binding)
if err != nil {
return "", nil
}
return template.HTML(result), err
},
"current": func() (string, error) {
return name, nil
},
"partial": func(partialName string, binding interface{}) (template.HTML, error) {
fullPartialName := fmt.Sprintf("%s-%s", partialName, name)
if s.Templates.Lookup(fullPartialName) != nil {
result, err := s.executeTemplateBuf(fullPartialName, binding)
return template.HTML(result), err
}
return "", nil
},
// partial related to current page,
// it would be easier for adding pages' style/script inline
// for example when using partial_r '.script' in layout.html
// templates/users/index.html would load templates/users/index.script.html
"partial_r": func(partialName string, binding interface{}) (template.HTML, error) {
ext := filepath.Ext(name)
root := name[:len(name)-len(ext)]
fullPartialName := fmt.Sprintf("%s%s%s", root, partialName, ext)
if s.Templates.Lookup(fullPartialName) != nil {
result, err := s.executeTemplateBuf(fullPartialName, binding)
return template.HTML(result), err
}
return "", nil
},
"render": func(fullPartialName string, binding interface{}) (template.HTML, error) {
result, err := s.executeTemplateBuf(fullPartialName, binding)
return template.HTML(result), err
},
}
The text was updated successfully, but these errors were encountered: