Skip to content

Commit

Permalink
feat: Template.HTML.Command.Input ( Fixes #1076 )
Browse files Browse the repository at this point in the history
Supporting -ElementSeparator and hiding some parameters from web.
  • Loading branch information
James Brundage committed Mar 29, 2024
1 parent ba4482f commit 6d58bba
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Template function HTML.Command.Input {
.EXAMPLE
New-WebPage -Content @(
Get-Command Template.HTML.Command.Input | Template.HTML.Command.Input
)
) -Palette "Konsolas"
#>
[CmdletBinding(DefaultParameterSetName='None')]
param(
Expand Down Expand Up @@ -110,6 +110,7 @@ Template function HTML.Command.Input {
# The Element Map.
# This maps parameters to the HTML elements that will be used to render them.
[vbn()]
[Management.Automation.Hidden()]
[Alias('ElementNameMap','ElementNames')]
[PSObject]
$ElementMap = [Ordered]@{
Expand All @@ -124,6 +125,7 @@ Template function HTML.Command.Input {
# The Element Attribute Map.
# This maps parameters to the HTML element attributes that will be used to render them.
[vbn()]
[Management.Automation.Hidden()]
[PSObject]
$ElementAttributeMap = [Ordered]@{
'Example' = [Ordered]@{
Expand All @@ -135,7 +137,7 @@ Template function HTML.Command.Input {
# The element separator. This is used to separate elements.
[vbn()]
[psobject]
$ElementSeparator,
$ElementSeparator = '<br/>',

# The Command Attributes. These are used to provide additional information about the command.
# They will be automatically provided if piping a command into this function.
Expand All @@ -146,7 +148,7 @@ Template function HTML.Command.Input {
$Attribute,

# The Container Element. This is used to hold all of the elements.
[vbn()]
[vbn()]
[string]
$ContainerElement,

Expand Down Expand Up @@ -210,7 +212,7 @@ Template function HTML.Command.Input {
# Many parameters will be turned directly into elements,
# using the -ElementMap and -ElementAttributeMap
foreach ($potentialElement in $elementOrder) {
if ($myParameterCopy.($potentialElement)) {
@(if ($myParameterCopy.($potentialElement)) {
$ElementSplat = [Ordered]@{
Name = $elementMap.$potentialElement
Content = "$($myParameterCopy.$potentialElement)"
Expand All @@ -219,7 +221,7 @@ Template function HTML.Command.Input {
$ElementSplat.Attribute = $ElementAttributeMap.$potentialElement
}
Template.HTML.Element @ElementSplat
}
}) -join $ElementSeparator
}

# Any parameters should be turned into input elements.
Expand Down

0 comments on commit 6d58bba

Please sign in to comment.