dovetail
1.0.0
현재 알파에서 API가 변경됩니다
선적 서류 비치
Swiftui/React/Elm에서 영감을 얻은 사용자 및 개발자 친화적 인 HTML 구성 요소.
Render (
w ,
Div (
Header (
Nav (
AriaLabel ( "Primary" ),
List (
Link ( "/" , Text ( "Home" )),
Link ( "/about" , Text ( "About" )),
Link ( "/pricing" , Text ( "Pricing" ), AriaCurrentPage ),
Link ( "/sign-in" , Text ( "Sign In" )),
Link ( "/join" , Text ( "Join" )),
),
),
),
Main (
Article (
H ( 1 , Text ( "Welcome" )),
P ( "Render HTML using components with Go" ),
),
FormTo ( "/newsletter" ). With (
FieldLabelled ( "Email" , Textbox ( "email" )),
SubmitButton ( Text ( "Sign up for the newsletter" )),
),
),
)
) 유형 : HTMLElementView
Main(children ...HTMLView) - <main>Nav(children ...HTMLView) - <nav>Header(children ...HTMLView) - <header>Footer(children ...HTMLView) - <footer>Section(children ...HTMLView) - <section>Article(children ...HTMLView) - <article>Aside(children ...HTMLView) - <aside>Div(children ...HTMLView) - <div>List(children ...HTMLView) - <ul><li>{ children[0] }</li>…<li>{ children[n] }</li></ul>Ul(children ...HTMLView) - <ul>Li(children ...HTMLView) - <li><ol> , <dl>Link(url string, children ...HTMLView) - <a href="{ url }">{ children }</a>Button(children ...HTMLView) - <button type="button">{ children }</button>Img(srcUrl string, alt string, enhancers ...HTMLEnhancer) - <img src="{ srcUrl }" alt="{ alt }" {...enhancers}>P(children ...HTMLView) - <p>TextWith(text string, enhancers ...HTMLEnhancer) - <span {...enhancers}>{ text }</span>Noscript(children ...HTMLView) - <noscript>{ children }</noscript>FormTo(action string, options ...func(form FormHTMLView) FormHTMLView) - <form>Multipart(form FormHTMLView) FormHTMLView <form enctype="multipart/form-data">Textbox(inputName string, options ...FieldTextInputOption) - <input type="text">SubmitButton(children ...HTMLView) - <button type="submit">{ children }</button>Text(text string) - HTML 텍스트 노드When(when bool, view HTMLView) - true 인 when 에만 제공된 view 렌더링합니다.HTMLElementViewOf(tagName string, tagAtom atom.Atom, children []HTMLView) - 사용자 정의 html 요소 AriaAttr - aria-*AriaLabel - aria-labelCustomAttr - 사용자 정의 HTML 속성DataAttr - data-* 속성 구성 요소는 함수를 사용하여 정의됩니다. 이러한 기능은 여러 인수를 취하고 다른 구성 요소의 복합재를 반환 할 수 있습니다.
func PrimaryButton ( text string ) View {
return Button ( Text ( text )). Class ( "btn btn-primary" )
} 가장 빠른 HTML 생산자가 되려고 노력하지는 않지만 Dovetail은 html/template 보다 빠르게 구문 분석하고 실행하는 것을 목표로합니다.
make test_bench Dovetail의 수행 방식을 확인하여 다양한 HTML 구성 요소를 생성합니다. 2016 15 ″ MacBook Pro의 결과는 다음과 같습니다.
go test -p 1 -timeout 30s -bench="Bench" -benchmem -v -run "Bench" ./...
goos: darwin
goarch: amd64
pkg: github.com/RoyalIcing/dovetail
BenchmarkTailwindJustDiv-8 4758601 247 ns/op 272 B/op 2 allocs/op
BenchmarkTailwind0Classes-8 4620313 249 ns/op 272 B/op 2 allocs/op
BenchmarkTailwind2Classes-8 2074034 580 ns/op 400 B/op 6 allocs/op
BenchmarkTailwind4Classes-8 1713938 694 ns/op 464 B/op 7 allocs/op
BenchmarkTailwind8Classes-8 1349778 887 ns/op 640 B/op 8 allocs/op
BenchmarkTailwindAddClasses2Classes-8 1990402 601 ns/op 416 B/op 6 allocs/op
BenchmarkTailwindAddClasses4Classes-8 1771840 677 ns/op 480 B/op 6 allocs/op
BenchmarkTailwindAddClasses8Classes-8 1504893 783 ns/op 656 B/op 6 allocs/op
BenchmarkTailwindDivWithClasses8Classes-8 1757682 729 ns/op 528 B/op 5 allocs/op
BenchmarkTailwindChangeClasses2Classes-8 1797513 643 ns/op 464 B/op 8 allocs/op
BenchmarkTailwindChangeClasses4Classes-8 1533936 790 ns/op 560 B/op 9 allocs/op
BenchmarkTailwindChangeClasses8Classes-8 1234028 970 ns/op 800 B/op 10 allocs/op
BenchmarkText-8 7639869 154 ns/op 128 B/op 2 allocs/op
BenchmarkHeader-8 4320638 251 ns/op 272 B/op 2 allocs/op
BenchmarkDiv-8 4858587 242 ns/op 272 B/op 2 allocs/op
BenchmarkDivWithClasses1-8 2697412 445 ns/op 336 B/op 4 allocs/op
BenchmarkDivWithClasses2Together-8 2296304 519 ns/op 368 B/op 5 allocs/op
BenchmarkDivWithClasses2-8 2066386 576 ns/op 384 B/op 6 allocs/op
BenchmarkDivWithChildClassNames-8 1734169 672 ns/op 448 B/op 9 allocs/op
BenchmarkButton-8 2446404 478 ns/op 352 B/op 5 allocs/op
BenchmarkButtonSubmit-8 2451301 480 ns/op 352 B/op 5 allocs/op
BenchmarkH1-8 2267946 521 ns/op 448 B/op 6 allocs/op
PASS
ok github.com/RoyalIcing/dovetail 39.216s
GCP App Engine 표준에서 저렴하게 호스팅 할 수있는 서버 렌더링 된 웹 앱을 만들고 싶기 때문입니다.
개발자 친화적 인 사용자 친화적 인 (빠른로드, 액세스 가능)를 원합니다.