Skip to content

Commit d9e0185

Browse files
author
James Brundage
committed
fix: Get-Htmx ( Fixes #6 )
Handling dynamically added child content
1 parent fd1c35a commit d9e0185

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Commands/Get-Htmx.ps1

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ function Get-HTMX {
77
88
The function has no explicit parameters.
99
10-
Instead, broadly speaking, arguments become attributes (unless it appears to be a tag) and inputs become children.
10+
Instead, broadly speaking, arguments become attributes (unless it appears to be a tag or has whitespace) and inputs become children.
1111
.NOTES
1212
Ideally, this command is very forgiving in its input and helps you write HTMX tag in PowerShell.
1313
1414
If this proves not to be the case, feel free to open an issue.
1515
.EXAMPLE
1616
Get-Htmx div class=container "Hello, World!"
17-
<div class="container">Hello, World!</div>
1817
.EXAMPLE
19-
htmx button "Click Me" hx-get=api/endpoint hx-trigger=click
18+
htmx button "Click Me" hx-on:click="alert('Thanks, I needed that!')"
2019
#>
2120
[ArgumentCompleter({
2221
param(
@@ -144,14 +143,14 @@ function Get-HTMX {
144143
}
145144

146145
# If we do not have children, we can close the tag now.
147-
if (-not $allContent) { ' />'}
146+
if (-not $moreChildren) { ' />'}
148147
# Otherwise, we will close the tag after the children.
149148
else { '>'}
150149

151-
if ($allContent) {
150+
if ($moreChildren) {
152151
@(
153152
# We will walk over each child and create the child string.
154-
foreach ($contentItem in $allContent) {
153+
foreach ($contentItem in $moreChildren) {
155154
# If the content has a `ToHtml` method, we will use it.
156155
if ($contentItem.ToHtml.Invoke) {
157156
$contentItem.ToHtml()

0 commit comments

Comments
 (0)