go-html/path.go
Snider 78d5b45b0c
Some checks failed
Security Scan / security (push) Successful in 10s
Test / test (push) Failing after 36s
feat: modernise to Go 1.26 — iterators, slices/maps, EachSeq
- Add EachSeq[T](iter.Seq[T], fn) for iterator-based template rendering
- Use slices.Collect(maps.Keys()) + slices.Sort for deterministic attr output
- Use strings.SplitSeq in codegen TagToClassName and path parsing
- Use range over int in layout and pipeline loops
- Refresh go.sum

Co-Authored-By: Gemini <noreply@google.com>
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-23 05:11:22 +00:00

23 lines
466 B
Go

package html
import "strings"
// ParseBlockID extracts the slot sequence from a data-block ID.
// "L-0-C-0" → ['L', 'C']
func ParseBlockID(id string) []byte {
if id == "" {
return nil
}
// Split on "-" and take every other element (the slot letters).
// Format: "X-0" or "X-0-Y-0-Z-0"
var slots []byte
i := 0
for part := range strings.SplitSeq(id, "-") {
if i%2 == 0 && len(part) == 1 {
slots = append(slots, part[0])
}
i++
}
return slots
}