Skip to content

Commit d7e3f47

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

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Commands/Get-Htmx.ps1

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ 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 or has whitespace) 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.
15+
16+
The function determines which parameters are treated as attributes through several checks:
17+
18+
1. Piped input will always be treated as child elements.
19+
2. If the argument is a dictionary, its key-value pairs are treated as attributes.
20+
3. If the argument is a string containing an equals sign (e.g., "key=value"), it is split into a key and value, and added as an attribute.
21+
4. If an argument is a string and does not match certain patterns (e.g., it does not look like a tag or an attribute), it is used as the tag name.
22+
5. If an argument is whitespace or a colon/equals sign, it is skipped.
23+
6. If an attribute key is detected without a value, the next argument is treated as its value.
24+
7. If the last key is content, child, or children, the argument is treated as a child element.
1525
.EXAMPLE
1626
Get-Htmx div class=container "Hello, World!"
1727
.EXAMPLE

0 commit comments

Comments
 (0)