Skip to content

Commit

Permalink
use templ.Component in all utils
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartaccent committed Jan 29, 2025
1 parent 3cc256a commit 36037f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion element_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package gtml
import (
"bytes"
"context"
"github.com/a-h/templ"
"testing"
)

// Helper function to simplify rendering a Element and capturing the output.
func renderElement(t *testing.T, node *Element) string {
func renderElement(t *testing.T, node templ.Component) string {
var buf bytes.Buffer
err := node.Render(context.Background(), &buf)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
)

// If returns the element if the condition is true, otherwise returns an empty element.
func If(condition bool, element *Element) *Element {
func If(condition bool, element templ.Component) templ.Component {
if condition {
return element
}
return Empty()
}

// IfElse returns the truthy element if the condition is true, otherwise returns the falsy element.
func IfElse(condition bool, truthyElement, falsyElement *Element) *Element {
func IfElse(condition bool, truthyElement, falsyElement templ.Component) templ.Component {
if condition {
return truthyElement
}
Expand Down

0 comments on commit 36037f6

Please sign in to comment.