Source File
raw.go
Belonging Package
github.com/pancsta/go-app/pkg/app
package appimport ()// Raw creates a UI element from the given raw HTML string. The raw HTML must// have a single root element. If the root tag cannot be determined, it defaults// to a div element.//// Using Raw can be risky since there's no validation of the provided// string content. Ensure that the content is safe and sanitized before use.func ( string) UI {= strings.TrimSpace():= rawRootTagName()if == "" {= "<div></div>"}return &raw{value: ,tag: ,}}type raw struct {jsElement ValueparentElement UItreeDepth uinttag stringvalue string}func ( *raw) () Value {return .jsElement}func ( *raw) () bool {return .jsElement != nil}func ( *raw) () uint {return .treeDepth}func ( *raw) () UI {return .parentElement}func ( *raw) ( UI) UI {.parentElement =return}func rawRootTagName( string) string {= strings.TrimSpace()if strings.HasPrefix(, "</") || !strings.HasPrefix(, "<") {return ""}:= -1for := 1; < len(); ++ {if [] == ' ' ||[] == '\t' ||[] == '\n' ||[] == '>' {=break}}if <= 0 {return ""}return [1:]}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |