mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-02 22:52:51 +02:00
@@ -15,6 +15,7 @@ package template
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"iter"
|
||||
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
template "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate"
|
||||
@@ -38,6 +39,19 @@ func (t *Template) Prepare() (*template.Template, error) {
|
||||
return t.text, nil
|
||||
}
|
||||
|
||||
func (t *Template) All() iter.Seq[*Template] {
|
||||
return func(yield func(t *Template) bool) {
|
||||
ns := t.nameSpace
|
||||
ns.mu.Lock()
|
||||
defer ns.mu.Unlock()
|
||||
for _, v := range ns.set {
|
||||
if !yield(v) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See https://github.com/golang/go/issues/5884
|
||||
func StripTags(html string) string {
|
||||
return stripTags(html)
|
||||
|
@@ -17,6 +17,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"iter"
|
||||
"reflect"
|
||||
|
||||
"github.com/gohugoio/hugo/common/herrors"
|
||||
@@ -433,3 +434,18 @@ func (s *state) evalCall(dot, fun reflect.Value, isBuiltin bool, node parse.Node
|
||||
func isTrue(val reflect.Value) (truth, ok bool) {
|
||||
return hreflect.IsTruthfulValue(val), true
|
||||
}
|
||||
|
||||
func (t *Template) All() iter.Seq[*Template] {
|
||||
return func(yield func(t *Template) bool) {
|
||||
if t.common == nil {
|
||||
return
|
||||
}
|
||||
t.muTmpl.RLock()
|
||||
defer t.muTmpl.RUnlock()
|
||||
for _, v := range t.tmpl {
|
||||
if !yield(v) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -533,7 +533,7 @@ func (t *Tree) parseControl(context string) (pos Pos, line int, pipe *PipeNode,
|
||||
t.rangeDepth--
|
||||
}
|
||||
switch next.Type() {
|
||||
case nodeEnd: //done
|
||||
case nodeEnd: // done
|
||||
case nodeElse:
|
||||
// Special case for "else if" and "else with".
|
||||
// If the "else" is followed immediately by an "if" or "with",
|
||||
|
Reference in New Issue
Block a user