Skip to content

Commit cea03df

Browse files
committed
Html helper methods
1 parent 49e13c3 commit cea03df

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

htmlhelper/button.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package htmlhelper
2+
3+
import (
4+
. "github.com/kirillrdy/nadeshiko/html"
5+
"github.com/sparkymat/webdsl/css"
6+
)
7+
8+
func SubmitButton(text string, iconClasses ...css.Class) Node {
9+
return Button().Type("submit").Children(
10+
Span().Text(text),
11+
I().Class(iconClasses...),
12+
)
13+
}

htmlhelper/email_field.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package htmlhelper
2+
3+
import (
4+
. "github.com/kirillrdy/nadeshiko/html"
5+
)
6+
7+
func EmailField() Node {
8+
return Input().Type("email").Name("email").Placeholder("E-mail")
9+
}

htmlhelper/link_to.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package htmlhelper
2+
3+
import (
4+
. "github.com/kirillrdy/nadeshiko/html"
5+
"github.com/sparkymat/webdsl/http"
6+
)
7+
8+
func ButtonLink(url string, method http.Method, text string) Node {
9+
return Form().Action(url).Method(string(method)).Children(
10+
Button().Type("submit").Children(
11+
Span().Text(text),
12+
),
13+
)
14+
}
15+
16+
func ContainerLink(url string, innerNodes ...Node) Node {
17+
return A().Href(url).Children(innerNodes...)
18+
}

htmlhelper/password_field.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package htmlhelper
2+
3+
import (
4+
. "github.com/kirillrdy/nadeshiko/html"
5+
)
6+
7+
func PasswordField() Node {
8+
return Input().Type("password").Name("password").Placeholder("Password")
9+
}

0 commit comments

Comments
 (0)