From 960fa28b365eb34e15e74b72ec1a16036d2a234a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Thu, 23 Apr 2026 23:05:37 +0200 Subject: [PATCH 01/23] Remove the C# solution --- Html.slnx | 3 --- src/Html.csproj | 28 ---------------------------- 2 files changed, 31 deletions(-) delete mode 100644 Html.slnx delete mode 100644 src/Html.csproj diff --git a/Html.slnx b/Html.slnx deleted file mode 100644 index c2cf796..0000000 --- a/Html.slnx +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Html.csproj b/src/Html.csproj deleted file mode 100644 index 8e4f6ed..0000000 --- a/src/Html.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - Cedric-Belin.fr - © Cédric Belin - PowerShell cmdlets for rendering HTML documents. - HTML Renderer for PS - 1.2.0 - - - - false - Belin.Html - true - enable - enable - ../bin - Belin.Html - net10.0 - - - - - - - - - - From 528ab2e33dad156a7cd5416a93491062f45bfa4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Thu, 23 Apr 2026 23:56:44 +0200 Subject: [PATCH 02/23] Add the `Format-KebabCaseLower` cmdlet --- src/Format-KebabCaseLower.psm1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/Format-KebabCaseLower.psm1 diff --git a/src/Format-KebabCaseLower.psm1 b/src/Format-KebabCaseLower.psm1 new file mode 100644 index 0000000..81ccb0c --- /dev/null +++ b/src/Format-KebabCaseLower.psm1 @@ -0,0 +1,24 @@ +using namespace System.Text.Json + +<# +.SYNOPSIS + Converts the specified name according to lowercase kebab-casing. +.INPUTS + The name to convert. +.OUTPUTS + The converted name. +#> +function Format-KebabCaseLower { + [CmdletBinding()] + [OutputType([string])] + param ( + # The name to convert. + [Parameter(Mandatory, Position = 0)] + [AllowEmptyString()] + [string] $InputObject + ) + + process { + [JsonNamingPolicy]::KebabCaseLower.ConvertName($InputObject) + } +} From b17339a84048416489b53032f1b4163675213ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:09:09 +0200 Subject: [PATCH 03/23] Update the project URL --- ChangeLog.md | 26 +++++++++++++------------- Html.psd1 | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index ef0cab8..3354d8b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,58 +1,58 @@ # Changelog -## Version [1.2.0](https://github.com/cedx/html.net/compare/v1.1.0...v1.2.0) +## Version [1.2.0](https://github.com/cedx/html.ps1/compare/v1.1.0...v1.2.0) - Added the `Use-Layout` and `Write-View` cmdlets. -## Version [1.1.0](https://github.com/cedx/html.net/compare/v1.0.1...v1.1.0) +## Version [1.1.0](https://github.com/cedx/html.ps1/compare/v1.0.1...v1.1.0) - Added support for `[switch]` parameters in attribute values. - The `New-DelElement`, `New-InsElement` and `New-TimeElement` cmdlets now use a non-terminating error. -## Version [1.0.1](https://github.com/cedx/html.net/compare/v1.0.0...v1.0.1) +## Version [1.0.1](https://github.com/cedx/html.ps1/compare/v1.0.0...v1.0.1) - Fixed a packaging issue: the generated cmdlets were not included in the release. -## Version [1.0.0](https://github.com/cedx/html.net/compare/v0.10.0...v1.0.0) +## Version [1.0.0](https://github.com/cedx/html.ps1/compare/v0.10.0...v1.0.0) - Added the `New-FormElement`, `New-IframeElement`, `New-InputElement`, `New-TemplateElement` and `New-TextareaElement` cmdlets. - Added the `form`, `iframe`, `input`, `template` and `textarea` aliases. -## Version [0.10.0](https://github.com/cedx/html.net/compare/v0.9.0...v0.10.0) +## Version [0.10.0](https://github.com/cedx/html.ps1/compare/v0.9.0...v0.10.0) - Added the `New-ButtonElement`, `New-QElement`, `New-SelectElement`, `New-SlotElement` and `New-SourceElement` cmdlets. - Added the `button`, `q`, `selectTag`, `slot` and `source` aliases. - The common parameter `-Style` is now an `OrderedHashtable`, allowing the declaration order to be preserved. -## Version [0.9.0](https://github.com/cedx/html.net/compare/v0.8.0...v0.9.0) +## Version [0.9.0](https://github.com/cedx/html.ps1/compare/v0.8.0...v0.9.0) - Added the `New-OlElement`, `New-OptgroupElement`, `New-OptionElement`, `New-OutputElement` and `New-ProgressElement` cmdlets. - Added the `ol`, `optgroup`, `option`, `output` and `progress` aliases. -## Version [0.8.0](https://github.com/cedx/html.net/compare/v0.7.0...v0.8.0) +## Version [0.8.0](https://github.com/cedx/html.ps1/compare/v0.7.0...v0.8.0) - Added the `New-LabelElement`, `New-LiElement`, `New-MapElement`, `New-MeterElement` and `New-ObjectElement` cmdlets. - Added the `label`, `li`, `map`, `meter` and `object` aliases. - Renamed the common parameter `-Data` to `-DataSet`. -## Version [0.7.0](https://github.com/cedx/html.net/compare/v0.6.0...v0.7.0) +## Version [0.7.0](https://github.com/cedx/html.ps1/compare/v0.6.0...v0.7.0) - Added the `New-DetailsElement`, `New-DialogElement`, `New-EmbedElement`, `New-FieldsetElement` and `New-InsElement` cmdlets. - Added the `details`, `dialog`, `embed`, `fieldset` and `ins` aliases. -## Version [0.6.0](https://github.com/cedx/html.net/compare/v0.5.0...v0.6.0) +## Version [0.6.0](https://github.com/cedx/html.ps1/compare/v0.5.0...v0.6.0) - Added the `Html` prefix to the nouns of all cmdlets. - Added the `New-DelElement`, `New-TdElement`, `New-ThElement`, `New-TimeElement` and `New-TrackElement` cmdlets. - Added the `delTag`, `td`, `th`, `time` and `track` aliases. -## Version [0.5.0](https://github.com/cedx/html.net/compare/v0.4.0...v0.5.0) +## Version [0.5.0](https://github.com/cedx/html.ps1/compare/v0.4.0...v0.5.0) - Added the `New-ColGroupElement`, `New-DataElement`, `New-StyleElement` and `New-VideoElement` cmdlets. - Added the `colgroup`, `dataTag`, `style` and `video` aliases. -## Version [0.4.0](https://github.com/cedx/html.net/compare/v0.3.0...v0.4.0) +## Version [0.4.0](https://github.com/cedx/html.ps1/compare/v0.3.0...v0.4.0) - Added support for the `on*` and `tabindex` attributes. - Added the `New-AudioElement`, `New-BlockquoteElement`, `New-CanvasElement` and `New-ColElement` cmdlets. - Added the `audio`, `blockquote`, `canvas` and `col` aliases. - Renamed the `New-Doctype` cmdlet to `New-DocumentType`. -## Version [0.3.0](https://github.com/cedx/html.net/compare/v0.2.0...v0.3.0) +## Version [0.3.0](https://github.com/cedx/html.ps1/compare/v0.2.0...v0.3.0) - Added support for the `data-*`, `dir`, `lang` and `title` attributes. - Added the `New-AElement`, `New-AreaElement`, `New-ImgElement` and `New-ScriptElement` cmdlets. - Added the `a`, `area`, `img` and `script` aliases. -## Version [0.2.0](https://github.com/cedx/html.net/compare/v0.1.0...v0.2.0) +## Version [0.2.0](https://github.com/cedx/html.ps1/compare/v0.1.0...v0.2.0) - Added the `New-BaseElement`, `New-HtmlElement`, `New-LinkElement` and `New-MetaElement` cmdlets. - Added the `base`, `html`, `link` and `meta` aliases. diff --git a/Html.psd1 b/Html.psd1 index d454a57..3f4b628 100644 --- a/Html.psd1 +++ b/Html.psd1 @@ -137,9 +137,9 @@ PrivateData = @{ PSData = @{ - LicenseUri = "https://github.com/cedx/html.net/blob/main/License.md" - ProjectUri = "https://github.com/cedx/html.net" - ReleaseNotes = "https://github.com/cedx/html.net/releases" + LicenseUri = "https://github.com/cedx/html.ps1/blob/main/License.md" + ProjectUri = "https://github.com/cedx/html.ps1" + ReleaseNotes = "https://github.com/cedx/html.ps1/releases" Tags = "html", "renderer", "template", "templating", "web" } } From 0f54d3bf24aa557ea6a880c6f565dbebcd9111e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:10:21 +0200 Subject: [PATCH 04/23] Update the project name --- ReadMe.md | 12 ++++++------ docs/Installation.md | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index 87b3432..c1bca09 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,13 +1,13 @@ -# HTML Renderer for PS +# HTML Renderer for PowerShell [PowerShell](https://learn.microsoft.com/en-us/powershell) cmdlets for rendering [HTML](https://developer.mozilla.org/docs/Web/HTML) documents. ## Documentation -- [User guide](https://github.com/cedx/html.net/tree/main/docs) -- [Examples](https://github.com/cedx/html.net/tree/main/example) +- [User guide](https://github.com/cedx/html.ps1/tree/main/docs) +- [Examples](https://github.com/cedx/html.ps1/tree/main/example) ## Development -- [Git repository](https://github.com/cedx/html.net) -- [Submit an issue](https://github.com/cedx/html.net/issues) +- [Git repository](https://github.com/cedx/html.ps1) +- [Submit an issue](https://github.com/cedx/html.ps1/issues) ## License -[HTML Renderer for PS](https://github.com/cedx/html.net) is distributed under the MIT License. +[HTML Renderer for PowerShell](https://github.com/cedx/html.ps1) is distributed under the MIT License. diff --git a/docs/Installation.md b/docs/Installation.md index 1774d7d..f41318c 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -1,7 +1,7 @@ # Installation ## Requirements -Before installing **HTML Renderer for PS**, you need to make sure you have [PowerShell](https://learn.microsoft.com/en-us/powershell) up and running. +Before installing **HTML Renderer for PowerShell**, you need to make sure you have [PowerShell](https://learn.microsoft.com/en-us/powershell) up and running. You can verify if you're already good to go with the following command: ```shell From 9e57d6e40067fc628ffb444785bb472f10464cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:14:58 +0200 Subject: [PATCH 05/23] Update the build system --- tool/Assets.ps1 | 4 +- tool/Build.ps1 | 5 --- tool/Clean.ps1 | 2 - tool/Cmdlets.psm1 | 106 ++++++---------------------------------------- tool/Default.ps1 | 2 - tool/Format.ps1 | 4 -- tool/Install.ps1 | 3 -- tool/Lint.ps1 | 2 +- tool/Outdated.ps1 | 1 - tool/Publish.ps1 | 23 ++-------- tool/Test.ps1 | 9 ++-- tool/Update.ps1 | 3 -- tool/Version.ps1 | 5 --- tool/Watch.ps1 | 5 --- 14 files changed, 23 insertions(+), 151 deletions(-) delete mode 100644 tool/Build.ps1 delete mode 100644 tool/Format.ps1 delete mode 100644 tool/Version.ps1 delete mode 100644 tool/Watch.ps1 diff --git a/tool/Assets.ps1 b/tool/Assets.ps1 index 7c166c0..d0b9068 100644 --- a/tool/Assets.ps1 +++ b/tool/Assets.ps1 @@ -15,11 +15,11 @@ foreach ($element in (Import-PowerShellDataFile share/HtmlElements.psd1).Element $cmdletsToExport.Add("New-Html$($parameters.CapitalizedTag)Element") $fileName = "New-$($parameters.CapitalizedTag)Element" - if (Test-Path "src/Elements/$fileName.cs") { continue } + if (Test-Path "src/Elements/$fileName.psm1") { continue } $content = $cmdletTemplate foreach ($key in $parameters.Keys) { $content = $content -replace "{$key}", $parameters.$key } - Set-Content "src/Generated/$fileName.g.cs" $content -NoNewline + Set-Content "src/Generated/$fileName.g.psm1" $content -NoNewline } $cmdletsToExport.Sort() diff --git a/tool/Build.ps1 b/tool/Build.ps1 deleted file mode 100644 index ad2af98..0000000 --- a/tool/Build.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -using module ./Cmdlets.psm1 -& "$PSScriptRoot/Assets.ps1" - -"Building the solution..." -Build-DotNetSolution ($Release ? "Release" : "Debug") diff --git a/tool/Clean.ps1 b/tool/Clean.ps1 index d5e902d..af77604 100644 --- a/tool/Clean.ps1 +++ b/tool/Clean.ps1 @@ -1,4 +1,2 @@ "Deleting all generated files..." -Remove-Item bin, src/Generated -ErrorAction Ignore -Force -Recurse -Remove-Item */obj -Force -Recurse Remove-Item var/* -Exclude .gitkeep -Force -Recurse diff --git a/tool/Cmdlets.psm1 b/tool/Cmdlets.psm1 index bc2d5fa..d7e2f45 100644 --- a/tool/Cmdlets.psm1 +++ b/tool/Cmdlets.psm1 @@ -1,69 +1,8 @@ -using namespace System.Diagnostics.CodeAnalysis - -<# -.SYNOPSIS - Builds the .NET solution and all of its dependencies. -#> -function Build-DotNetSolution { - param ( - # The configuration to use for generating the project. - [Parameter(Position = 0)] - [string] $Configuration - ) - - $argumentList = $Configuration ? "--configuration", $Configuration : @() - dotnet build @argumentList -} - -<# -.SYNOPSIS - Applies style preferences and static analysis recommendations to the .NET solution. -#> -function Format-DotNetSolution { - dotnet format -} - -<# -.SYNOPSIS - Invokes the .NET test runner. -#> -function Invoke-DotNetTest { - param ( - # The path to the settings file to use for running the tests. - [ValidateScript({ Test-Path $_ -PathType Leaf }, ErrorMessage = "The specified settings file does not exist.")] - [string] $Settings - ) - - $argumentList = $Settings ? "--settings", $Settings : @() - dotnet test @argumentList -} - -<# -.SYNOPSIS - Invokes the PowerShell test runner. -#> -function Invoke-PowerShellTest { - param ( - # The path to the file or directory to be tested. - [Parameter(Mandatory, Position = 0)] - [string[]] $Path, - - # Value indicating whether, on completion of the tests, to exit the PowerShell session - # and return an exit code equal to the number of failed tests. - [switch] $EnableExit - ) - - Import-Module Pester - Invoke-Pester $Path - if ($EnableExit) { exit $LASTEXITCODE } -} - <# .SYNOPSIS Creates a new Git tag. #> function New-GitTag { - [SuppressMessage("PSUseShouldProcessForStateChangingFunctions", "")] param ( # The tag name. [Parameter(Mandatory, Position = 0)] @@ -76,42 +15,21 @@ function New-GitTag { <# .SYNOPSIS - Publishes the project package to the NuGet registry. + Publishes the project package to the PowerShell Gallery registry. #> -function Publish-NuGetPackage { - param ( - # Value indicating whether to not build the solution before compression. - [switch] $NoBuild - ) +function Publish-PSGalleryModule { + $root = Join-Path $PSScriptRoot .. - $output = "$PSScriptRoot/../var/NuGet" - $argumentList = "--output", $output - if ($NoBuild) { $argumentList += "--no-build" } - dotnet pack @argumentList - foreach ($package in Get-Item $output/*.nupkg) { dotnet nuget push $package --api-key $Env:NUGET_API_KEY --source NuGet } -} + $output = "$root/var/PSModule" + New-Item $output -ItemType Directory | Out-Null + Copy-Item $root/Html.psd1 $output/Belin.Html.psd1 + Copy-Item $root/*.md $output + Copy-Item $root/src $output -Recurse -<# -.SYNOPSIS - Installs the specified NuGet package, if any. Otherwise, installs all packages. -#> -function Restore-NuGetPackage { - param ( - # The package to install. - [Parameter(Position = 0)] - [string] $Package - ) - - if ($Package) { dotnet package add $Package } - else { dotnet restore } -} - -<# -.SYNOPSIS - Checks whether an update is available for the NuGet packages. -#> -function Test-NuGetPackageUpdate { - dotnet package list --outdated + $output = "$root/var/PSGallery" + New-Item $output -ItemType Directory | Out-Null + Compress-PSResource $root/var/PSModule $output + foreach ($package in Get-Item $output/*.nupkg) { Publish-PSResource -ApiKey $Env:PSGALLERY_API_KEY -NupkgPath $package -Repository PSGallery } } <# diff --git a/tool/Default.ps1 b/tool/Default.ps1 index b3a7a6a..4e1a44f 100644 --- a/tool/Default.ps1 +++ b/tool/Default.ps1 @@ -1,3 +1 @@ & "$PSScriptRoot/Clean.ps1" -& "$PSScriptRoot/Version.ps1" -& "$PSScriptRoot/Build.ps1" diff --git a/tool/Format.ps1 b/tool/Format.ps1 deleted file mode 100644 index 4b16ae6..0000000 --- a/tool/Format.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -using module ./Cmdlets.psm1 - -"Formatting the source code..." -Format-DotNetSolution diff --git a/tool/Install.ps1 b/tool/Install.ps1 index 4795143..6687fd2 100644 --- a/tool/Install.ps1 +++ b/tool/Install.ps1 @@ -1,5 +1,2 @@ -using module ./Cmdlets.psm1 - "Installing the dependencies..." Install-PSResource -RequiredResourceFile PSModules.psd1 -TrustRepository -WarningAction Ignore -Restore-NuGetPackage diff --git a/tool/Lint.ps1 b/tool/Lint.ps1 index 50086db..4a26630 100644 --- a/tool/Lint.ps1 +++ b/tool/Lint.ps1 @@ -1,5 +1,5 @@ using module PSScriptAnalyzer "Performing the static analysis of source code..." -Invoke-ScriptAnalyzer $PSScriptRoot, "test" -Recurse +$PSScriptRoot, "src", "test" | Invoke-ScriptAnalyzer -ExcludeRule PSUseShouldProcessForStateChangingFunctions -Recurse Test-ModuleManifest Html.psd1 | Out-Null diff --git a/tool/Outdated.ps1 b/tool/Outdated.ps1 index e228eee..35b5327 100644 --- a/tool/Outdated.ps1 +++ b/tool/Outdated.ps1 @@ -2,4 +2,3 @@ using module ./Cmdlets.psm1 "Checking for outdated dependencies..." (Import-PowerShellDataFile PSModules.psd1).Keys | Get-InstalledPSResource | Test-PSResourceUpdate -Test-NuGetPackageUpdate diff --git a/tool/Publish.ps1 b/tool/Publish.ps1 index b23e112..d92ea26 100644 --- a/tool/Publish.ps1 +++ b/tool/Publish.ps1 @@ -1,24 +1,7 @@ using module ./Cmdlets.psm1 - -if ($Release) { & "$PSScriptRoot/Default.ps1" } -else { - "The ""-Release"" switch must be set!" - exit 1 -} +& "$PSScriptRoot/Default.ps1" "Publishing the package..." -$module = Import-PowerShellDataFile Html.psd1 -$version = $module.ModuleVersion +$version = (Import-PowerShellDataFile Html.psd1).ModuleVersion New-GitTag "v$version" - -$output = "var/PSModule" -New-Item $output/bin, $output/src -ItemType Directory | Out-Null -Copy-Item Html.psd1 $output/Belin.Html.psd1 -Copy-Item *.md $output -Copy-Item src/*.psm1 $output/src -Recurse -$module.RootModule | Copy-Item -Destination $output/bin - -$output = "var/PSGallery" -New-Item $output -ItemType Directory | Out-Null -Compress-PSResource var/PSModule $output -Get-Item "$output/*.nupkg" | ForEach-Object { Publish-PSResource -ApiKey $Env:PSGALLERY_API_KEY -NupkgPath $_ -Repository PSGallery } +Publish-PSGalleryModule diff --git a/tool/Test.ps1 b/tool/Test.ps1 index 3095a97..226e684 100644 --- a/tool/Test.ps1 +++ b/tool/Test.ps1 @@ -1,5 +1,6 @@ -using module ./Cmdlets.psm1 -& "$PSScriptRoot/Build.ps1" - "Running the test suite..." -Invoke-PowerShellTest test -EnableExit +pwsh -Command { + Import-Module Pester + Invoke-Pester test + exit $LASTEXITCODE +} diff --git a/tool/Update.ps1 b/tool/Update.ps1 index 19d51aa..6c564d1 100644 --- a/tool/Update.ps1 +++ b/tool/Update.ps1 @@ -1,5 +1,2 @@ -using module ./Cmdlets.psm1 - "Updating the dependencies..." (Import-PowerShellDataFile PSModules.psd1).Keys | Update-PSResource -TrustRepository -Restore-NuGetPackage diff --git a/tool/Version.ps1 b/tool/Version.ps1 deleted file mode 100644 index e532688..0000000 --- a/tool/Version.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -"Updating the version number in the sources..." -$version = (Import-PowerShellDataFile Html.psd1).ModuleVersion -foreach ($file in Get-ChildItem -Filter *.csproj -Recurse) { - (Get-Content $file -Raw) -replace "\d+(\.\d+){2}.*", "$version" | Set-Content $file -NoNewLine -} diff --git a/tool/Watch.ps1 b/tool/Watch.ps1 deleted file mode 100644 index 4240334..0000000 --- a/tool/Watch.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -& "$PSScriptRoot/Assets.ps1" - -"Watching for file changes..." -$configuration = $Release ? "Release" : "Debug" -Start-Process dotnet -ArgumentList "watch", "build", "--configuration", $configuration -NoNewWindow -Wait -WorkingDirectory src From 563553a128f38c5943de44bae31dc5de89acefbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:15:36 +0200 Subject: [PATCH 06/23] Rename the `Format-KebabCaseLower` cmdlet to `Format-KebabCase` [skip ci] --- src/{Format-KebabCaseLower.psm1 => Format-KebabCase.psm1} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/{Format-KebabCaseLower.psm1 => Format-KebabCase.psm1} (92%) diff --git a/src/Format-KebabCaseLower.psm1 b/src/Format-KebabCase.psm1 similarity index 92% rename from src/Format-KebabCaseLower.psm1 rename to src/Format-KebabCase.psm1 index 81ccb0c..d1451ca 100644 --- a/src/Format-KebabCaseLower.psm1 +++ b/src/Format-KebabCase.psm1 @@ -8,7 +8,7 @@ using namespace System.Text.Json .OUTPUTS The converted name. #> -function Format-KebabCaseLower { +function Format-KebabCase { [CmdletBinding()] [OutputType([string])] param ( From 1973f57fcf2fd1ff94b5a3988f86d694932c3fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:16:52 +0200 Subject: [PATCH 07/23] Update the CI --- .github/workflows/ContinuousIntegration.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ContinuousIntegration.yaml b/.github/workflows/ContinuousIntegration.yaml index 0ef586a..4d2ae6d 100644 --- a/.github/workflows/ContinuousIntegration.yaml +++ b/.github/workflows/ContinuousIntegration.yaml @@ -11,10 +11,6 @@ jobs: steps: - name: Fetch sources uses: actions/checkout@v6 - - name: Set up .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: 10 - name: Set up PowerShell run: | Invoke-WebRequest "https://aka.ms/install-powershell.ps1" -OutFile Install-PowerShell.ps1 From 6bd9f0cc2f7be98ffd37b467b99f7f4e31a6b03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:18:06 +0200 Subject: [PATCH 08/23] Update the VSCode settings --- .editorconfig | 20 -------------------- .vscode/extensions.json | 1 - .vscode/launch.json | 1 - .vscode/tasks.json | 11 ----------- src/Generated/New-AbbrElement.g.cs | 5 +++++ src/Generated/New-AddressElement.g.cs | 7 +++++++ src/Generated/New-ArticleElement.g.cs | 7 +++++++ src/Generated/New-AsideElement.g.cs | 7 +++++++ src/Generated/New-BElement.g.cs | 7 +++++++ src/Generated/New-BdiElement.g.cs | 7 +++++++ src/Generated/New-BdoElement.g.cs | 7 +++++++ src/Generated/New-BodyElement.g.cs | 7 +++++++ src/Generated/New-BrElement.g.cs | 7 +++++++ src/Generated/New-CaptionElement.g.cs | 7 +++++++ src/Generated/New-CiteElement.g.cs | 7 +++++++ src/Generated/New-CodeElement.g.cs | 7 +++++++ src/Generated/New-DatalistElement.g.cs | 7 +++++++ src/Generated/New-DdElement.g.cs | 7 +++++++ src/Generated/New-DfnElement.g.cs | 7 +++++++ src/Generated/New-DivElement.g.cs | 7 +++++++ src/Generated/New-DlElement.g.cs | 7 +++++++ src/Generated/New-DtElement.g.cs | 7 +++++++ src/Generated/New-EmElement.g.cs | 7 +++++++ src/Generated/New-FigcaptionElement.g.cs | 7 +++++++ src/Generated/New-FigureElement.g.cs | 7 +++++++ src/Generated/New-FooterElement.g.cs | 7 +++++++ src/Generated/New-H1Element.g.cs | 7 +++++++ src/Generated/New-H2Element.g.cs | 7 +++++++ src/Generated/New-H3Element.g.cs | 7 +++++++ src/Generated/New-H4Element.g.cs | 7 +++++++ src/Generated/New-H5Element.g.cs | 7 +++++++ src/Generated/New-H6Element.g.cs | 7 +++++++ src/Generated/New-HeadElement.g.cs | 7 +++++++ src/Generated/New-HeaderElement.g.cs | 7 +++++++ src/Generated/New-HgroupElement.g.cs | 7 +++++++ src/Generated/New-HrElement.g.cs | 7 +++++++ src/Generated/New-HtmlElement.g.cs | 7 +++++++ src/Generated/New-IElement.g.cs | 7 +++++++ src/Generated/New-KbdElement.g.cs | 7 +++++++ src/Generated/New-LegendElement.g.cs | 7 +++++++ src/Generated/New-MainElement.g.cs | 7 +++++++ src/Generated/New-MarkElement.g.cs | 7 +++++++ src/Generated/New-MenuElement.g.cs | 7 +++++++ src/Generated/New-NavElement.g.cs | 7 +++++++ src/Generated/New-NoscriptElement.g.cs | 7 +++++++ src/Generated/New-PElement.g.cs | 7 +++++++ src/Generated/New-PictureElement.g.cs | 7 +++++++ src/Generated/New-PreElement.g.cs | 7 +++++++ src/Generated/New-RpElement.g.cs | 7 +++++++ src/Generated/New-RtElement.g.cs | 7 +++++++ src/Generated/New-RubyElement.g.cs | 7 +++++++ src/Generated/New-SElement.g.cs | 7 +++++++ src/Generated/New-SampElement.g.cs | 7 +++++++ src/Generated/New-SearchElement.g.cs | 7 +++++++ src/Generated/New-SectionElement.g.cs | 7 +++++++ src/Generated/New-SmallElement.g.cs | 7 +++++++ src/Generated/New-SpanElement.g.cs | 7 +++++++ src/Generated/New-StrongElement.g.cs | 7 +++++++ src/Generated/New-SubElement.g.cs | 7 +++++++ src/Generated/New-SummaryElement.g.cs | 7 +++++++ src/Generated/New-SupElement.g.cs | 7 +++++++ src/Generated/New-TableElement.g.cs | 7 +++++++ src/Generated/New-TbodyElement.g.cs | 7 +++++++ src/Generated/New-TfootElement.g.cs | 7 +++++++ src/Generated/New-TheadElement.g.cs | 7 +++++++ src/Generated/New-TitleElement.g.cs | 7 +++++++ src/Generated/New-TrElement.g.cs | 7 +++++++ src/Generated/New-UElement.g.cs | 7 +++++++ src/Generated/New-UlElement.g.cs | 7 +++++++ src/Generated/New-VarElement.g.cs | 7 +++++++ src/Generated/New-WbrElement.g.cs | 7 +++++++ 71 files changed, 467 insertions(+), 33 deletions(-) delete mode 100644 .vscode/tasks.json create mode 100644 src/Generated/New-AbbrElement.g.cs create mode 100644 src/Generated/New-AddressElement.g.cs create mode 100644 src/Generated/New-ArticleElement.g.cs create mode 100644 src/Generated/New-AsideElement.g.cs create mode 100644 src/Generated/New-BElement.g.cs create mode 100644 src/Generated/New-BdiElement.g.cs create mode 100644 src/Generated/New-BdoElement.g.cs create mode 100644 src/Generated/New-BodyElement.g.cs create mode 100644 src/Generated/New-BrElement.g.cs create mode 100644 src/Generated/New-CaptionElement.g.cs create mode 100644 src/Generated/New-CiteElement.g.cs create mode 100644 src/Generated/New-CodeElement.g.cs create mode 100644 src/Generated/New-DatalistElement.g.cs create mode 100644 src/Generated/New-DdElement.g.cs create mode 100644 src/Generated/New-DfnElement.g.cs create mode 100644 src/Generated/New-DivElement.g.cs create mode 100644 src/Generated/New-DlElement.g.cs create mode 100644 src/Generated/New-DtElement.g.cs create mode 100644 src/Generated/New-EmElement.g.cs create mode 100644 src/Generated/New-FigcaptionElement.g.cs create mode 100644 src/Generated/New-FigureElement.g.cs create mode 100644 src/Generated/New-FooterElement.g.cs create mode 100644 src/Generated/New-H1Element.g.cs create mode 100644 src/Generated/New-H2Element.g.cs create mode 100644 src/Generated/New-H3Element.g.cs create mode 100644 src/Generated/New-H4Element.g.cs create mode 100644 src/Generated/New-H5Element.g.cs create mode 100644 src/Generated/New-H6Element.g.cs create mode 100644 src/Generated/New-HeadElement.g.cs create mode 100644 src/Generated/New-HeaderElement.g.cs create mode 100644 src/Generated/New-HgroupElement.g.cs create mode 100644 src/Generated/New-HrElement.g.cs create mode 100644 src/Generated/New-HtmlElement.g.cs create mode 100644 src/Generated/New-IElement.g.cs create mode 100644 src/Generated/New-KbdElement.g.cs create mode 100644 src/Generated/New-LegendElement.g.cs create mode 100644 src/Generated/New-MainElement.g.cs create mode 100644 src/Generated/New-MarkElement.g.cs create mode 100644 src/Generated/New-MenuElement.g.cs create mode 100644 src/Generated/New-NavElement.g.cs create mode 100644 src/Generated/New-NoscriptElement.g.cs create mode 100644 src/Generated/New-PElement.g.cs create mode 100644 src/Generated/New-PictureElement.g.cs create mode 100644 src/Generated/New-PreElement.g.cs create mode 100644 src/Generated/New-RpElement.g.cs create mode 100644 src/Generated/New-RtElement.g.cs create mode 100644 src/Generated/New-RubyElement.g.cs create mode 100644 src/Generated/New-SElement.g.cs create mode 100644 src/Generated/New-SampElement.g.cs create mode 100644 src/Generated/New-SearchElement.g.cs create mode 100644 src/Generated/New-SectionElement.g.cs create mode 100644 src/Generated/New-SmallElement.g.cs create mode 100644 src/Generated/New-SpanElement.g.cs create mode 100644 src/Generated/New-StrongElement.g.cs create mode 100644 src/Generated/New-SubElement.g.cs create mode 100644 src/Generated/New-SummaryElement.g.cs create mode 100644 src/Generated/New-SupElement.g.cs create mode 100644 src/Generated/New-TableElement.g.cs create mode 100644 src/Generated/New-TbodyElement.g.cs create mode 100644 src/Generated/New-TfootElement.g.cs create mode 100644 src/Generated/New-TheadElement.g.cs create mode 100644 src/Generated/New-TitleElement.g.cs create mode 100644 src/Generated/New-TrElement.g.cs create mode 100644 src/Generated/New-UElement.g.cs create mode 100644 src/Generated/New-UlElement.g.cs create mode 100644 src/Generated/New-VarElement.g.cs create mode 100644 src/Generated/New-WbrElement.g.cs diff --git a/.editorconfig b/.editorconfig index cd706d2..57b794d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,26 +8,6 @@ insert_final_newline = true tab_width = 2 trim_trailing_whitespace = true -[*.cs] -csharp_indent_case_contents_when_block = false -csharp_indent_labels = no_change -csharp_new_line_before_open_brace = none -csharp_prefer_braces = false -csharp_space_after_cast = true -csharp_space_before_colon_in_inheritance_clause = false -csharp_style_expression_bodied_constructors = true -csharp_style_expression_bodied_local_functions = true -csharp_style_expression_bodied_methods = true -csharp_style_expression_bodied_operators = true -csharp_style_namespace_declarations = file_scoped -csharp_style_var_elsewhere = true -csharp_style_var_for_built_in_types = true -csharp_style_var_when_type_is_apparent = true -csharp_using_directive_placement = inside_namespace -dotnet_diagnostic.CS8524.severity = silent -dotnet_sort_system_directives_first = false -dotnet_style_namespace_match_folder = false - [*.md] trim_trailing_whitespace = false diff --git a/.vscode/extensions.json b/.vscode/extensions.json index e2d0e78..b408c54 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,5 @@ { "recommendations": [ - "ms-dotnettools.csdevkit", "ms-vscode.powershell" ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index ec38296..93c907c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,7 +3,6 @@ "configurations": [ { "name": "Script", - "preLaunchTask": "Build", "request": "launch", "type": "PowerShell", "script": "${workspaceFolder}/Debug.ps1" diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index b3a0bfc..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Build", - "type": "shell", - "command": "./Invoke.ps1", - "args": ["Build"] - } - ] -} diff --git a/src/Generated/New-AbbrElement.g.cs b/src/Generated/New-AbbrElement.g.cs new file mode 100644 index 0000000..a5ed9ab --- /dev/null +++ b/src/Generated/New-AbbrElement.g.cs @@ -0,0 +1,5 @@ +/// +/// Creates a new abbr element. +/// +[Cmdlet(VerbsCommon.New, "HtmlAbbrElement"), Alias("abbr"), OutputType(typeof(string))] +public class NewAbbrElementCommand(): NewElementCommand("abbr", isVoid: false) {} diff --git a/src/Generated/New-AddressElement.g.cs b/src/Generated/New-AddressElement.g.cs new file mode 100644 index 0000000..fe830cb --- /dev/null +++ b/src/Generated/New-AddressElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new address element. +/// +[Cmdlet(VerbsCommon.New, "HtmlAddressElement"), Alias("address"), OutputType(typeof(string))] +public class NewAddressElementCommand(): NewElementCommand("address", isVoid: false) {} diff --git a/src/Generated/New-ArticleElement.g.cs b/src/Generated/New-ArticleElement.g.cs new file mode 100644 index 0000000..6e89373 --- /dev/null +++ b/src/Generated/New-ArticleElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new article element. +/// +[Cmdlet(VerbsCommon.New, "HtmlArticleElement"), Alias("article"), OutputType(typeof(string))] +public class NewArticleElementCommand(): NewElementCommand("article", isVoid: false) {} diff --git a/src/Generated/New-AsideElement.g.cs b/src/Generated/New-AsideElement.g.cs new file mode 100644 index 0000000..9e76a03 --- /dev/null +++ b/src/Generated/New-AsideElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new aside element. +/// +[Cmdlet(VerbsCommon.New, "HtmlAsideElement"), Alias("aside"), OutputType(typeof(string))] +public class NewAsideElementCommand(): NewElementCommand("aside", isVoid: false) {} diff --git a/src/Generated/New-BElement.g.cs b/src/Generated/New-BElement.g.cs new file mode 100644 index 0000000..1460c85 --- /dev/null +++ b/src/Generated/New-BElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new b element. +/// +[Cmdlet(VerbsCommon.New, "HtmlBElement"), Alias("b"), OutputType(typeof(string))] +public class NewBElementCommand(): NewElementCommand("b", isVoid: false) {} diff --git a/src/Generated/New-BdiElement.g.cs b/src/Generated/New-BdiElement.g.cs new file mode 100644 index 0000000..1ab6d1f --- /dev/null +++ b/src/Generated/New-BdiElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new bdi element. +/// +[Cmdlet(VerbsCommon.New, "HtmlBdiElement"), Alias("bdi"), OutputType(typeof(string))] +public class NewBdiElementCommand(): NewElementCommand("bdi", isVoid: false) {} diff --git a/src/Generated/New-BdoElement.g.cs b/src/Generated/New-BdoElement.g.cs new file mode 100644 index 0000000..44a0a1c --- /dev/null +++ b/src/Generated/New-BdoElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new bdo element. +/// +[Cmdlet(VerbsCommon.New, "HtmlBdoElement"), Alias("bdo"), OutputType(typeof(string))] +public class NewBdoElementCommand(): NewElementCommand("bdo", isVoid: false) {} diff --git a/src/Generated/New-BodyElement.g.cs b/src/Generated/New-BodyElement.g.cs new file mode 100644 index 0000000..cfb1cb0 --- /dev/null +++ b/src/Generated/New-BodyElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new body element. +/// +[Cmdlet(VerbsCommon.New, "HtmlBodyElement"), Alias("body"), OutputType(typeof(string))] +public class NewBodyElementCommand(): NewElementCommand("body", isVoid: false) {} diff --git a/src/Generated/New-BrElement.g.cs b/src/Generated/New-BrElement.g.cs new file mode 100644 index 0000000..c6beef7 --- /dev/null +++ b/src/Generated/New-BrElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new br element. +/// +[Cmdlet(VerbsCommon.New, "HtmlBrElement"), Alias("br"), OutputType(typeof(string))] +public class NewBrElementCommand(): NewElementCommand("br", isVoid: true) {} diff --git a/src/Generated/New-CaptionElement.g.cs b/src/Generated/New-CaptionElement.g.cs new file mode 100644 index 0000000..99c0088 --- /dev/null +++ b/src/Generated/New-CaptionElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new caption element. +/// +[Cmdlet(VerbsCommon.New, "HtmlCaptionElement"), Alias("caption"), OutputType(typeof(string))] +public class NewCaptionElementCommand(): NewElementCommand("caption", isVoid: false) {} diff --git a/src/Generated/New-CiteElement.g.cs b/src/Generated/New-CiteElement.g.cs new file mode 100644 index 0000000..b5450f5 --- /dev/null +++ b/src/Generated/New-CiteElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new cite element. +/// +[Cmdlet(VerbsCommon.New, "HtmlCiteElement"), Alias("cite"), OutputType(typeof(string))] +public class NewCiteElementCommand(): NewElementCommand("cite", isVoid: false) {} diff --git a/src/Generated/New-CodeElement.g.cs b/src/Generated/New-CodeElement.g.cs new file mode 100644 index 0000000..a6af442 --- /dev/null +++ b/src/Generated/New-CodeElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new code element. +/// +[Cmdlet(VerbsCommon.New, "HtmlCodeElement"), Alias("code"), OutputType(typeof(string))] +public class NewCodeElementCommand(): NewElementCommand("code", isVoid: false) {} diff --git a/src/Generated/New-DatalistElement.g.cs b/src/Generated/New-DatalistElement.g.cs new file mode 100644 index 0000000..099e56e --- /dev/null +++ b/src/Generated/New-DatalistElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new datalist element. +/// +[Cmdlet(VerbsCommon.New, "HtmlDatalistElement"), Alias("datalist"), OutputType(typeof(string))] +public class NewDatalistElementCommand(): NewElementCommand("datalist", isVoid: false) {} diff --git a/src/Generated/New-DdElement.g.cs b/src/Generated/New-DdElement.g.cs new file mode 100644 index 0000000..4a5bb8e --- /dev/null +++ b/src/Generated/New-DdElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new dd element. +/// +[Cmdlet(VerbsCommon.New, "HtmlDdElement"), Alias("dd"), OutputType(typeof(string))] +public class NewDdElementCommand(): NewElementCommand("dd", isVoid: false) {} diff --git a/src/Generated/New-DfnElement.g.cs b/src/Generated/New-DfnElement.g.cs new file mode 100644 index 0000000..f3b8cff --- /dev/null +++ b/src/Generated/New-DfnElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new dfn element. +/// +[Cmdlet(VerbsCommon.New, "HtmlDfnElement"), Alias("dfn"), OutputType(typeof(string))] +public class NewDfnElementCommand(): NewElementCommand("dfn", isVoid: false) {} diff --git a/src/Generated/New-DivElement.g.cs b/src/Generated/New-DivElement.g.cs new file mode 100644 index 0000000..1d1e9d0 --- /dev/null +++ b/src/Generated/New-DivElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new div element. +/// +[Cmdlet(VerbsCommon.New, "HtmlDivElement"), Alias("div"), OutputType(typeof(string))] +public class NewDivElementCommand(): NewElementCommand("div", isVoid: false) {} diff --git a/src/Generated/New-DlElement.g.cs b/src/Generated/New-DlElement.g.cs new file mode 100644 index 0000000..de8c9de --- /dev/null +++ b/src/Generated/New-DlElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new dl element. +/// +[Cmdlet(VerbsCommon.New, "HtmlDlElement"), Alias("dl"), OutputType(typeof(string))] +public class NewDlElementCommand(): NewElementCommand("dl", isVoid: false) {} diff --git a/src/Generated/New-DtElement.g.cs b/src/Generated/New-DtElement.g.cs new file mode 100644 index 0000000..864a3d1 --- /dev/null +++ b/src/Generated/New-DtElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new dt element. +/// +[Cmdlet(VerbsCommon.New, "HtmlDtElement"), Alias("dt"), OutputType(typeof(string))] +public class NewDtElementCommand(): NewElementCommand("dt", isVoid: false) {} diff --git a/src/Generated/New-EmElement.g.cs b/src/Generated/New-EmElement.g.cs new file mode 100644 index 0000000..2e6eb39 --- /dev/null +++ b/src/Generated/New-EmElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new em element. +/// +[Cmdlet(VerbsCommon.New, "HtmlEmElement"), Alias("em"), OutputType(typeof(string))] +public class NewEmElementCommand(): NewElementCommand("em", isVoid: false) {} diff --git a/src/Generated/New-FigcaptionElement.g.cs b/src/Generated/New-FigcaptionElement.g.cs new file mode 100644 index 0000000..899499a --- /dev/null +++ b/src/Generated/New-FigcaptionElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new figcaption element. +/// +[Cmdlet(VerbsCommon.New, "HtmlFigcaptionElement"), Alias("figcaption"), OutputType(typeof(string))] +public class NewFigcaptionElementCommand(): NewElementCommand("figcaption", isVoid: false) {} diff --git a/src/Generated/New-FigureElement.g.cs b/src/Generated/New-FigureElement.g.cs new file mode 100644 index 0000000..9ee85c7 --- /dev/null +++ b/src/Generated/New-FigureElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new figure element. +/// +[Cmdlet(VerbsCommon.New, "HtmlFigureElement"), Alias("figure"), OutputType(typeof(string))] +public class NewFigureElementCommand(): NewElementCommand("figure", isVoid: false) {} diff --git a/src/Generated/New-FooterElement.g.cs b/src/Generated/New-FooterElement.g.cs new file mode 100644 index 0000000..3af2bbf --- /dev/null +++ b/src/Generated/New-FooterElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new footer element. +/// +[Cmdlet(VerbsCommon.New, "HtmlFooterElement"), Alias("footer"), OutputType(typeof(string))] +public class NewFooterElementCommand(): NewElementCommand("footer", isVoid: false) {} diff --git a/src/Generated/New-H1Element.g.cs b/src/Generated/New-H1Element.g.cs new file mode 100644 index 0000000..0bf9661 --- /dev/null +++ b/src/Generated/New-H1Element.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new h1 element. +/// +[Cmdlet(VerbsCommon.New, "HtmlH1Element"), Alias("h1"), OutputType(typeof(string))] +public class NewH1ElementCommand(): NewElementCommand("h1", isVoid: false) {} diff --git a/src/Generated/New-H2Element.g.cs b/src/Generated/New-H2Element.g.cs new file mode 100644 index 0000000..7bbd96d --- /dev/null +++ b/src/Generated/New-H2Element.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new h2 element. +/// +[Cmdlet(VerbsCommon.New, "HtmlH2Element"), Alias("h2"), OutputType(typeof(string))] +public class NewH2ElementCommand(): NewElementCommand("h2", isVoid: false) {} diff --git a/src/Generated/New-H3Element.g.cs b/src/Generated/New-H3Element.g.cs new file mode 100644 index 0000000..ebae03e --- /dev/null +++ b/src/Generated/New-H3Element.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new h3 element. +/// +[Cmdlet(VerbsCommon.New, "HtmlH3Element"), Alias("h3"), OutputType(typeof(string))] +public class NewH3ElementCommand(): NewElementCommand("h3", isVoid: false) {} diff --git a/src/Generated/New-H4Element.g.cs b/src/Generated/New-H4Element.g.cs new file mode 100644 index 0000000..a39cec8 --- /dev/null +++ b/src/Generated/New-H4Element.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new h4 element. +/// +[Cmdlet(VerbsCommon.New, "HtmlH4Element"), Alias("h4"), OutputType(typeof(string))] +public class NewH4ElementCommand(): NewElementCommand("h4", isVoid: false) {} diff --git a/src/Generated/New-H5Element.g.cs b/src/Generated/New-H5Element.g.cs new file mode 100644 index 0000000..64d3675 --- /dev/null +++ b/src/Generated/New-H5Element.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new h5 element. +/// +[Cmdlet(VerbsCommon.New, "HtmlH5Element"), Alias("h5"), OutputType(typeof(string))] +public class NewH5ElementCommand(): NewElementCommand("h5", isVoid: false) {} diff --git a/src/Generated/New-H6Element.g.cs b/src/Generated/New-H6Element.g.cs new file mode 100644 index 0000000..013eba2 --- /dev/null +++ b/src/Generated/New-H6Element.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new h6 element. +/// +[Cmdlet(VerbsCommon.New, "HtmlH6Element"), Alias("h6"), OutputType(typeof(string))] +public class NewH6ElementCommand(): NewElementCommand("h6", isVoid: false) {} diff --git a/src/Generated/New-HeadElement.g.cs b/src/Generated/New-HeadElement.g.cs new file mode 100644 index 0000000..f6fd9b3 --- /dev/null +++ b/src/Generated/New-HeadElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new head element. +/// +[Cmdlet(VerbsCommon.New, "HtmlHeadElement"), Alias("head"), OutputType(typeof(string))] +public class NewHeadElementCommand(): NewElementCommand("head", isVoid: false) {} diff --git a/src/Generated/New-HeaderElement.g.cs b/src/Generated/New-HeaderElement.g.cs new file mode 100644 index 0000000..fa0b4da --- /dev/null +++ b/src/Generated/New-HeaderElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new header element. +/// +[Cmdlet(VerbsCommon.New, "HtmlHeaderElement"), Alias("header"), OutputType(typeof(string))] +public class NewHeaderElementCommand(): NewElementCommand("header", isVoid: false) {} diff --git a/src/Generated/New-HgroupElement.g.cs b/src/Generated/New-HgroupElement.g.cs new file mode 100644 index 0000000..2d7407a --- /dev/null +++ b/src/Generated/New-HgroupElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new hgroup element. +/// +[Cmdlet(VerbsCommon.New, "HtmlHgroupElement"), Alias("hgroup"), OutputType(typeof(string))] +public class NewHgroupElementCommand(): NewElementCommand("hgroup", isVoid: false) {} diff --git a/src/Generated/New-HrElement.g.cs b/src/Generated/New-HrElement.g.cs new file mode 100644 index 0000000..679bf56 --- /dev/null +++ b/src/Generated/New-HrElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new hr element. +/// +[Cmdlet(VerbsCommon.New, "HtmlHrElement"), Alias("hr"), OutputType(typeof(string))] +public class NewHrElementCommand(): NewElementCommand("hr", isVoid: true) {} diff --git a/src/Generated/New-HtmlElement.g.cs b/src/Generated/New-HtmlElement.g.cs new file mode 100644 index 0000000..941ea4c --- /dev/null +++ b/src/Generated/New-HtmlElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new html element. +/// +[Cmdlet(VerbsCommon.New, "HtmlHtmlElement"), Alias("html"), OutputType(typeof(string))] +public class NewHtmlElementCommand(): NewElementCommand("html", isVoid: false) {} diff --git a/src/Generated/New-IElement.g.cs b/src/Generated/New-IElement.g.cs new file mode 100644 index 0000000..7727276 --- /dev/null +++ b/src/Generated/New-IElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new i element. +/// +[Cmdlet(VerbsCommon.New, "HtmlIElement"), Alias("i"), OutputType(typeof(string))] +public class NewIElementCommand(): NewElementCommand("i", isVoid: false) {} diff --git a/src/Generated/New-KbdElement.g.cs b/src/Generated/New-KbdElement.g.cs new file mode 100644 index 0000000..17732c7 --- /dev/null +++ b/src/Generated/New-KbdElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new kbd element. +/// +[Cmdlet(VerbsCommon.New, "HtmlKbdElement"), Alias("kbd"), OutputType(typeof(string))] +public class NewKbdElementCommand(): NewElementCommand("kbd", isVoid: false) {} diff --git a/src/Generated/New-LegendElement.g.cs b/src/Generated/New-LegendElement.g.cs new file mode 100644 index 0000000..1801213 --- /dev/null +++ b/src/Generated/New-LegendElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new legend element. +/// +[Cmdlet(VerbsCommon.New, "HtmlLegendElement"), Alias("legend"), OutputType(typeof(string))] +public class NewLegendElementCommand(): NewElementCommand("legend", isVoid: false) {} diff --git a/src/Generated/New-MainElement.g.cs b/src/Generated/New-MainElement.g.cs new file mode 100644 index 0000000..73e3c39 --- /dev/null +++ b/src/Generated/New-MainElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new main element. +/// +[Cmdlet(VerbsCommon.New, "HtmlMainElement"), Alias("main"), OutputType(typeof(string))] +public class NewMainElementCommand(): NewElementCommand("main", isVoid: false) {} diff --git a/src/Generated/New-MarkElement.g.cs b/src/Generated/New-MarkElement.g.cs new file mode 100644 index 0000000..17cfb7d --- /dev/null +++ b/src/Generated/New-MarkElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new mark element. +/// +[Cmdlet(VerbsCommon.New, "HtmlMarkElement"), Alias("mark"), OutputType(typeof(string))] +public class NewMarkElementCommand(): NewElementCommand("mark", isVoid: false) {} diff --git a/src/Generated/New-MenuElement.g.cs b/src/Generated/New-MenuElement.g.cs new file mode 100644 index 0000000..7b05e0d --- /dev/null +++ b/src/Generated/New-MenuElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new menu element. +/// +[Cmdlet(VerbsCommon.New, "HtmlMenuElement"), Alias("menu"), OutputType(typeof(string))] +public class NewMenuElementCommand(): NewElementCommand("menu", isVoid: false) {} diff --git a/src/Generated/New-NavElement.g.cs b/src/Generated/New-NavElement.g.cs new file mode 100644 index 0000000..8c92049 --- /dev/null +++ b/src/Generated/New-NavElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new nav element. +/// +[Cmdlet(VerbsCommon.New, "HtmlNavElement"), Alias("nav"), OutputType(typeof(string))] +public class NewNavElementCommand(): NewElementCommand("nav", isVoid: false) {} diff --git a/src/Generated/New-NoscriptElement.g.cs b/src/Generated/New-NoscriptElement.g.cs new file mode 100644 index 0000000..d252508 --- /dev/null +++ b/src/Generated/New-NoscriptElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new noscript element. +/// +[Cmdlet(VerbsCommon.New, "HtmlNoscriptElement"), Alias("noscript"), OutputType(typeof(string))] +public class NewNoscriptElementCommand(): NewElementCommand("noscript", isVoid: false) {} diff --git a/src/Generated/New-PElement.g.cs b/src/Generated/New-PElement.g.cs new file mode 100644 index 0000000..bcf82d1 --- /dev/null +++ b/src/Generated/New-PElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new p element. +/// +[Cmdlet(VerbsCommon.New, "HtmlPElement"), Alias("p"), OutputType(typeof(string))] +public class NewPElementCommand(): NewElementCommand("p", isVoid: false) {} diff --git a/src/Generated/New-PictureElement.g.cs b/src/Generated/New-PictureElement.g.cs new file mode 100644 index 0000000..d0a7c47 --- /dev/null +++ b/src/Generated/New-PictureElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new picture element. +/// +[Cmdlet(VerbsCommon.New, "HtmlPictureElement"), Alias("picture"), OutputType(typeof(string))] +public class NewPictureElementCommand(): NewElementCommand("picture", isVoid: false) {} diff --git a/src/Generated/New-PreElement.g.cs b/src/Generated/New-PreElement.g.cs new file mode 100644 index 0000000..774fb3f --- /dev/null +++ b/src/Generated/New-PreElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new pre element. +/// +[Cmdlet(VerbsCommon.New, "HtmlPreElement"), Alias("pre"), OutputType(typeof(string))] +public class NewPreElementCommand(): NewElementCommand("pre", isVoid: false) {} diff --git a/src/Generated/New-RpElement.g.cs b/src/Generated/New-RpElement.g.cs new file mode 100644 index 0000000..5555cbe --- /dev/null +++ b/src/Generated/New-RpElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new rp element. +/// +[Cmdlet(VerbsCommon.New, "HtmlRpElement"), Alias("rpTag"), OutputType(typeof(string))] +public class NewRpElementCommand(): NewElementCommand("rp", isVoid: false) {} diff --git a/src/Generated/New-RtElement.g.cs b/src/Generated/New-RtElement.g.cs new file mode 100644 index 0000000..d0a47bd --- /dev/null +++ b/src/Generated/New-RtElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new rt element. +/// +[Cmdlet(VerbsCommon.New, "HtmlRtElement"), Alias("rt"), OutputType(typeof(string))] +public class NewRtElementCommand(): NewElementCommand("rt", isVoid: false) {} diff --git a/src/Generated/New-RubyElement.g.cs b/src/Generated/New-RubyElement.g.cs new file mode 100644 index 0000000..c364ed0 --- /dev/null +++ b/src/Generated/New-RubyElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new ruby element. +/// +[Cmdlet(VerbsCommon.New, "HtmlRubyElement"), Alias("ruby"), OutputType(typeof(string))] +public class NewRubyElementCommand(): NewElementCommand("ruby", isVoid: false) {} diff --git a/src/Generated/New-SElement.g.cs b/src/Generated/New-SElement.g.cs new file mode 100644 index 0000000..6d4bbda --- /dev/null +++ b/src/Generated/New-SElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new s element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSElement"), Alias("s"), OutputType(typeof(string))] +public class NewSElementCommand(): NewElementCommand("s", isVoid: false) {} diff --git a/src/Generated/New-SampElement.g.cs b/src/Generated/New-SampElement.g.cs new file mode 100644 index 0000000..f17cc01 --- /dev/null +++ b/src/Generated/New-SampElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new samp element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSampElement"), Alias("samp"), OutputType(typeof(string))] +public class NewSampElementCommand(): NewElementCommand("samp", isVoid: false) {} diff --git a/src/Generated/New-SearchElement.g.cs b/src/Generated/New-SearchElement.g.cs new file mode 100644 index 0000000..a078aac --- /dev/null +++ b/src/Generated/New-SearchElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new search element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSearchElement"), Alias("search"), OutputType(typeof(string))] +public class NewSearchElementCommand(): NewElementCommand("search", isVoid: false) {} diff --git a/src/Generated/New-SectionElement.g.cs b/src/Generated/New-SectionElement.g.cs new file mode 100644 index 0000000..906b28c --- /dev/null +++ b/src/Generated/New-SectionElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new section element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSectionElement"), Alias("section"), OutputType(typeof(string))] +public class NewSectionElementCommand(): NewElementCommand("section", isVoid: false) {} diff --git a/src/Generated/New-SmallElement.g.cs b/src/Generated/New-SmallElement.g.cs new file mode 100644 index 0000000..ecfd905 --- /dev/null +++ b/src/Generated/New-SmallElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new small element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSmallElement"), Alias("small"), OutputType(typeof(string))] +public class NewSmallElementCommand(): NewElementCommand("small", isVoid: false) {} diff --git a/src/Generated/New-SpanElement.g.cs b/src/Generated/New-SpanElement.g.cs new file mode 100644 index 0000000..087a261 --- /dev/null +++ b/src/Generated/New-SpanElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new span element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSpanElement"), Alias("span"), OutputType(typeof(string))] +public class NewSpanElementCommand(): NewElementCommand("span", isVoid: false) {} diff --git a/src/Generated/New-StrongElement.g.cs b/src/Generated/New-StrongElement.g.cs new file mode 100644 index 0000000..811982f --- /dev/null +++ b/src/Generated/New-StrongElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new strong element. +/// +[Cmdlet(VerbsCommon.New, "HtmlStrongElement"), Alias("strong"), OutputType(typeof(string))] +public class NewStrongElementCommand(): NewElementCommand("strong", isVoid: false) {} diff --git a/src/Generated/New-SubElement.g.cs b/src/Generated/New-SubElement.g.cs new file mode 100644 index 0000000..528683c --- /dev/null +++ b/src/Generated/New-SubElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new sub element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSubElement"), Alias("sub"), OutputType(typeof(string))] +public class NewSubElementCommand(): NewElementCommand("sub", isVoid: false) {} diff --git a/src/Generated/New-SummaryElement.g.cs b/src/Generated/New-SummaryElement.g.cs new file mode 100644 index 0000000..f7a6789 --- /dev/null +++ b/src/Generated/New-SummaryElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new summary element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSummaryElement"), Alias("summary"), OutputType(typeof(string))] +public class NewSummaryElementCommand(): NewElementCommand("summary", isVoid: false) {} diff --git a/src/Generated/New-SupElement.g.cs b/src/Generated/New-SupElement.g.cs new file mode 100644 index 0000000..546ca97 --- /dev/null +++ b/src/Generated/New-SupElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new sup element. +/// +[Cmdlet(VerbsCommon.New, "HtmlSupElement"), Alias("sup"), OutputType(typeof(string))] +public class NewSupElementCommand(): NewElementCommand("sup", isVoid: false) {} diff --git a/src/Generated/New-TableElement.g.cs b/src/Generated/New-TableElement.g.cs new file mode 100644 index 0000000..819fc37 --- /dev/null +++ b/src/Generated/New-TableElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new table element. +/// +[Cmdlet(VerbsCommon.New, "HtmlTableElement"), Alias("table"), OutputType(typeof(string))] +public class NewTableElementCommand(): NewElementCommand("table", isVoid: false) {} diff --git a/src/Generated/New-TbodyElement.g.cs b/src/Generated/New-TbodyElement.g.cs new file mode 100644 index 0000000..114ccb9 --- /dev/null +++ b/src/Generated/New-TbodyElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new tbody element. +/// +[Cmdlet(VerbsCommon.New, "HtmlTbodyElement"), Alias("tbody"), OutputType(typeof(string))] +public class NewTbodyElementCommand(): NewElementCommand("tbody", isVoid: false) {} diff --git a/src/Generated/New-TfootElement.g.cs b/src/Generated/New-TfootElement.g.cs new file mode 100644 index 0000000..60b46a0 --- /dev/null +++ b/src/Generated/New-TfootElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new tfoot element. +/// +[Cmdlet(VerbsCommon.New, "HtmlTfootElement"), Alias("tfoot"), OutputType(typeof(string))] +public class NewTfootElementCommand(): NewElementCommand("tfoot", isVoid: false) {} diff --git a/src/Generated/New-TheadElement.g.cs b/src/Generated/New-TheadElement.g.cs new file mode 100644 index 0000000..fd5f6ec --- /dev/null +++ b/src/Generated/New-TheadElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new thead element. +/// +[Cmdlet(VerbsCommon.New, "HtmlTheadElement"), Alias("thead"), OutputType(typeof(string))] +public class NewTheadElementCommand(): NewElementCommand("thead", isVoid: false) {} diff --git a/src/Generated/New-TitleElement.g.cs b/src/Generated/New-TitleElement.g.cs new file mode 100644 index 0000000..a5fba7d --- /dev/null +++ b/src/Generated/New-TitleElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new title element. +/// +[Cmdlet(VerbsCommon.New, "HtmlTitleElement"), Alias("title"), OutputType(typeof(string))] +public class NewTitleElementCommand(): NewElementCommand("title", isVoid: false) {} diff --git a/src/Generated/New-TrElement.g.cs b/src/Generated/New-TrElement.g.cs new file mode 100644 index 0000000..00ad013 --- /dev/null +++ b/src/Generated/New-TrElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new tr element. +/// +[Cmdlet(VerbsCommon.New, "HtmlTrElement"), Alias("tr"), OutputType(typeof(string))] +public class NewTrElementCommand(): NewElementCommand("tr", isVoid: false) {} diff --git a/src/Generated/New-UElement.g.cs b/src/Generated/New-UElement.g.cs new file mode 100644 index 0000000..9f788fe --- /dev/null +++ b/src/Generated/New-UElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new u element. +/// +[Cmdlet(VerbsCommon.New, "HtmlUElement"), Alias("u"), OutputType(typeof(string))] +public class NewUElementCommand(): NewElementCommand("u", isVoid: false) {} diff --git a/src/Generated/New-UlElement.g.cs b/src/Generated/New-UlElement.g.cs new file mode 100644 index 0000000..4bcb65e --- /dev/null +++ b/src/Generated/New-UlElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new ul element. +/// +[Cmdlet(VerbsCommon.New, "HtmlUlElement"), Alias("ul"), OutputType(typeof(string))] +public class NewUlElementCommand(): NewElementCommand("ul", isVoid: false) {} diff --git a/src/Generated/New-VarElement.g.cs b/src/Generated/New-VarElement.g.cs new file mode 100644 index 0000000..99f1fe6 --- /dev/null +++ b/src/Generated/New-VarElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new var element. +/// +[Cmdlet(VerbsCommon.New, "HtmlVarElement"), Alias("var"), OutputType(typeof(string))] +public class NewVarElementCommand(): NewElementCommand("var", isVoid: false) {} diff --git a/src/Generated/New-WbrElement.g.cs b/src/Generated/New-WbrElement.g.cs new file mode 100644 index 0000000..55c62ec --- /dev/null +++ b/src/Generated/New-WbrElement.g.cs @@ -0,0 +1,7 @@ +namespace Belin.Html.Elements; + +/// +/// Creates a new wbr element. +/// +[Cmdlet(VerbsCommon.New, "HtmlWbrElement"), Alias("wbr"), OutputType(typeof(string))] +public class NewWbrElementCommand(): NewElementCommand("wbr", isVoid: true) {} From bf46eee9e847f88b9d2d45cbb151543566940a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:19:00 +0200 Subject: [PATCH 09/23] Update the Git settings [skip ci] --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0cffc73..f06f879 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ /**/*.user /.idea/ /.vs/ -/bin/ -/*/obj/ -/src/**/*.g.cs +/src/Generated/ /var/ From a5c937178368afd55ec22696a2d556da365ca884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:36:34 +0200 Subject: [PATCH 10/23] Bump the version number --- Html.psd1 | 130 +++++------------------------------------------------- 1 file changed, 12 insertions(+), 118 deletions(-) diff --git a/Html.psd1 b/Html.psd1 index 3f4b628..91f5bdb 100644 --- a/Html.psd1 +++ b/Html.psd1 @@ -1,7 +1,7 @@ @{ - ModuleVersion = "1.2.0" + # DefaultCommandPrefix = "Lcov" + ModuleVersion = "2.0.0" PowerShellVersion = "7.6" - RootModule = "bin/Belin.Html.dll" Author = "Cédric Belin " CompanyName = "Cedric-Belin.fr" @@ -9,124 +9,18 @@ Description = "PowerShell cmdlets for rendering HTML documents." GUID = "3c16800c-921e-4c31-9fc3-00052d2f30ba" - AliasesToExport = "doctype", "layout" - FunctionsToExport = "New-HtmlDocumentType", "Use-HtmlLayout", "Write-HtmlView" + CmdletsToExport = @() VariablesToExport = @() - CmdletsToExport = @( - "New-HtmlAbbrElement" - "New-HtmlAddressElement" - "New-HtmlAElement" - "New-HtmlAreaElement" - "New-HtmlArticleElement" - "New-HtmlAsideElement" - "New-HtmlAudioElement" - "New-HtmlBaseElement" - "New-HtmlBdiElement" - "New-HtmlBdoElement" - "New-HtmlBElement" - "New-HtmlBlockquoteElement" - "New-HtmlBodyElement" - "New-HtmlBrElement" - "New-HtmlButtonElement" - "New-HtmlCanvasElement" - "New-HtmlCaptionElement" - "New-HtmlCiteElement" - "New-HtmlCodeElement" - "New-HtmlColElement" - "New-HtmlColgroupElement" - "New-HtmlCustomElement" - "New-HtmlDataElement" - "New-HtmlDatalistElement" - "New-HtmlDdElement" - "New-HtmlDelElement" - "New-HtmlDetailsElement" - "New-HtmlDfnElement" - "New-HtmlDialogElement" - "New-HtmlDivElement" - "New-HtmlDlElement" - "New-HtmlDtElement" - "New-HtmlEmbedElement" - "New-HtmlEmElement" - "New-HtmlFieldsetElement" - "New-HtmlFigcaptionElement" - "New-HtmlFigureElement" - "New-HtmlFooterElement" - "New-HtmlFormElement" - "New-HtmlH1Element" - "New-HtmlH2Element" - "New-HtmlH3Element" - "New-HtmlH4Element" - "New-HtmlH5Element" - "New-HtmlH6Element" - "New-HtmlHeadElement" - "New-HtmlHeaderElement" - "New-HtmlHgroupElement" - "New-HtmlHrElement" - "New-HtmlHtmlElement" - "New-HtmlIElement" - "New-HtmlIframeElement" - "New-HtmlImgElement" - "New-HtmlInputElement" - "New-HtmlInsElement" - "New-HtmlKbdElement" - "New-HtmlLabelElement" - "New-HtmlLegendElement" - "New-HtmlLiElement" - "New-HtmlLinkElement" - "New-HtmlMainElement" - "New-HtmlMapElement" - "New-HtmlMarkElement" - "New-HtmlMenuElement" - "New-HtmlMetaElement" - "New-HtmlMeterElement" - "New-HtmlNavElement" - "New-HtmlNoscriptElement" - "New-HtmlObjectElement" - "New-HtmlOlElement" - "New-HtmlOptgroupElement" - "New-HtmlOptionElement" - "New-HtmlOutputElement" - "New-HtmlPElement" - "New-HtmlPictureElement" - "New-HtmlPreElement" - "New-HtmlProgressElement" - "New-HtmlQElement" - "New-HtmlRpElement" - "New-HtmlRtElement" - "New-HtmlRubyElement" - "New-HtmlSampElement" - "New-HtmlScriptElement" - "New-HtmlSearchElement" - "New-HtmlSectionElement" - "New-HtmlSelectElement" - "New-HtmlSElement" - "New-HtmlSlotElement" - "New-HtmlSmallElement" - "New-HtmlSourceElement" - "New-HtmlSpanElement" - "New-HtmlStrongElement" - "New-HtmlStyleElement" - "New-HtmlSubElement" - "New-HtmlSummaryElement" - "New-HtmlSupElement" - "New-HtmlTableElement" - "New-HtmlTbodyElement" - "New-HtmlTdElement" - "New-HtmlTemplateElement" - "New-HtmlTextareaElement" - "New-HtmlTfootElement" - "New-HtmlTheadElement" - "New-HtmlThElement" - "New-HtmlTimeElement" - "New-HtmlTitleElement" - "New-HtmlTrackElement" - "New-HtmlTrElement" - "New-HtmlUElement" - "New-HtmlUlElement" - "New-HtmlVarElement" - "New-HtmlVideoElement" - "New-HtmlWbrElement" + AliasesToExport = @( + "doctype" + "layout" + ) + + FunctionsToExport = @( + "New-HtmlDocumentType" + "Use-HtmlLayout" + "Write-HtmlView" ) NestedModules = @( From b16e188b38186d061b0f2ab2fbc05ef64445fad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:51:53 +0200 Subject: [PATCH 11/23] Remove the generated C# cmdlets [skip ci] --- src/Generated/New-AbbrElement.g.cs | 5 ----- src/Generated/New-AddressElement.g.cs | 7 ------- src/Generated/New-ArticleElement.g.cs | 7 ------- src/Generated/New-AsideElement.g.cs | 7 ------- src/Generated/New-BElement.g.cs | 7 ------- src/Generated/New-BdiElement.g.cs | 7 ------- src/Generated/New-BdoElement.g.cs | 7 ------- src/Generated/New-BodyElement.g.cs | 7 ------- src/Generated/New-BrElement.g.cs | 7 ------- src/Generated/New-CaptionElement.g.cs | 7 ------- src/Generated/New-CiteElement.g.cs | 7 ------- src/Generated/New-CodeElement.g.cs | 7 ------- src/Generated/New-DatalistElement.g.cs | 7 ------- src/Generated/New-DdElement.g.cs | 7 ------- src/Generated/New-DfnElement.g.cs | 7 ------- src/Generated/New-DivElement.g.cs | 7 ------- src/Generated/New-DlElement.g.cs | 7 ------- src/Generated/New-DtElement.g.cs | 7 ------- src/Generated/New-EmElement.g.cs | 7 ------- src/Generated/New-FigcaptionElement.g.cs | 7 ------- src/Generated/New-FigureElement.g.cs | 7 ------- src/Generated/New-FooterElement.g.cs | 7 ------- src/Generated/New-H1Element.g.cs | 7 ------- src/Generated/New-H2Element.g.cs | 7 ------- src/Generated/New-H3Element.g.cs | 7 ------- src/Generated/New-H4Element.g.cs | 7 ------- src/Generated/New-H5Element.g.cs | 7 ------- src/Generated/New-H6Element.g.cs | 7 ------- src/Generated/New-HeadElement.g.cs | 7 ------- src/Generated/New-HeaderElement.g.cs | 7 ------- src/Generated/New-HgroupElement.g.cs | 7 ------- src/Generated/New-HrElement.g.cs | 7 ------- src/Generated/New-HtmlElement.g.cs | 7 ------- src/Generated/New-IElement.g.cs | 7 ------- src/Generated/New-KbdElement.g.cs | 7 ------- src/Generated/New-LegendElement.g.cs | 7 ------- src/Generated/New-MainElement.g.cs | 7 ------- src/Generated/New-MarkElement.g.cs | 7 ------- src/Generated/New-MenuElement.g.cs | 7 ------- src/Generated/New-NavElement.g.cs | 7 ------- src/Generated/New-NoscriptElement.g.cs | 7 ------- src/Generated/New-PElement.g.cs | 7 ------- src/Generated/New-PictureElement.g.cs | 7 ------- src/Generated/New-PreElement.g.cs | 7 ------- src/Generated/New-RpElement.g.cs | 7 ------- src/Generated/New-RtElement.g.cs | 7 ------- src/Generated/New-RubyElement.g.cs | 7 ------- src/Generated/New-SElement.g.cs | 7 ------- src/Generated/New-SampElement.g.cs | 7 ------- src/Generated/New-SearchElement.g.cs | 7 ------- src/Generated/New-SectionElement.g.cs | 7 ------- src/Generated/New-SmallElement.g.cs | 7 ------- src/Generated/New-SpanElement.g.cs | 7 ------- src/Generated/New-StrongElement.g.cs | 7 ------- src/Generated/New-SubElement.g.cs | 7 ------- src/Generated/New-SummaryElement.g.cs | 7 ------- src/Generated/New-SupElement.g.cs | 7 ------- src/Generated/New-TableElement.g.cs | 7 ------- src/Generated/New-TbodyElement.g.cs | 7 ------- src/Generated/New-TfootElement.g.cs | 7 ------- src/Generated/New-TheadElement.g.cs | 7 ------- src/Generated/New-TitleElement.g.cs | 7 ------- src/Generated/New-TrElement.g.cs | 7 ------- src/Generated/New-UElement.g.cs | 7 ------- src/Generated/New-UlElement.g.cs | 7 ------- src/Generated/New-VarElement.g.cs | 7 ------- src/Generated/New-WbrElement.g.cs | 7 ------- 67 files changed, 467 deletions(-) delete mode 100644 src/Generated/New-AbbrElement.g.cs delete mode 100644 src/Generated/New-AddressElement.g.cs delete mode 100644 src/Generated/New-ArticleElement.g.cs delete mode 100644 src/Generated/New-AsideElement.g.cs delete mode 100644 src/Generated/New-BElement.g.cs delete mode 100644 src/Generated/New-BdiElement.g.cs delete mode 100644 src/Generated/New-BdoElement.g.cs delete mode 100644 src/Generated/New-BodyElement.g.cs delete mode 100644 src/Generated/New-BrElement.g.cs delete mode 100644 src/Generated/New-CaptionElement.g.cs delete mode 100644 src/Generated/New-CiteElement.g.cs delete mode 100644 src/Generated/New-CodeElement.g.cs delete mode 100644 src/Generated/New-DatalistElement.g.cs delete mode 100644 src/Generated/New-DdElement.g.cs delete mode 100644 src/Generated/New-DfnElement.g.cs delete mode 100644 src/Generated/New-DivElement.g.cs delete mode 100644 src/Generated/New-DlElement.g.cs delete mode 100644 src/Generated/New-DtElement.g.cs delete mode 100644 src/Generated/New-EmElement.g.cs delete mode 100644 src/Generated/New-FigcaptionElement.g.cs delete mode 100644 src/Generated/New-FigureElement.g.cs delete mode 100644 src/Generated/New-FooterElement.g.cs delete mode 100644 src/Generated/New-H1Element.g.cs delete mode 100644 src/Generated/New-H2Element.g.cs delete mode 100644 src/Generated/New-H3Element.g.cs delete mode 100644 src/Generated/New-H4Element.g.cs delete mode 100644 src/Generated/New-H5Element.g.cs delete mode 100644 src/Generated/New-H6Element.g.cs delete mode 100644 src/Generated/New-HeadElement.g.cs delete mode 100644 src/Generated/New-HeaderElement.g.cs delete mode 100644 src/Generated/New-HgroupElement.g.cs delete mode 100644 src/Generated/New-HrElement.g.cs delete mode 100644 src/Generated/New-HtmlElement.g.cs delete mode 100644 src/Generated/New-IElement.g.cs delete mode 100644 src/Generated/New-KbdElement.g.cs delete mode 100644 src/Generated/New-LegendElement.g.cs delete mode 100644 src/Generated/New-MainElement.g.cs delete mode 100644 src/Generated/New-MarkElement.g.cs delete mode 100644 src/Generated/New-MenuElement.g.cs delete mode 100644 src/Generated/New-NavElement.g.cs delete mode 100644 src/Generated/New-NoscriptElement.g.cs delete mode 100644 src/Generated/New-PElement.g.cs delete mode 100644 src/Generated/New-PictureElement.g.cs delete mode 100644 src/Generated/New-PreElement.g.cs delete mode 100644 src/Generated/New-RpElement.g.cs delete mode 100644 src/Generated/New-RtElement.g.cs delete mode 100644 src/Generated/New-RubyElement.g.cs delete mode 100644 src/Generated/New-SElement.g.cs delete mode 100644 src/Generated/New-SampElement.g.cs delete mode 100644 src/Generated/New-SearchElement.g.cs delete mode 100644 src/Generated/New-SectionElement.g.cs delete mode 100644 src/Generated/New-SmallElement.g.cs delete mode 100644 src/Generated/New-SpanElement.g.cs delete mode 100644 src/Generated/New-StrongElement.g.cs delete mode 100644 src/Generated/New-SubElement.g.cs delete mode 100644 src/Generated/New-SummaryElement.g.cs delete mode 100644 src/Generated/New-SupElement.g.cs delete mode 100644 src/Generated/New-TableElement.g.cs delete mode 100644 src/Generated/New-TbodyElement.g.cs delete mode 100644 src/Generated/New-TfootElement.g.cs delete mode 100644 src/Generated/New-TheadElement.g.cs delete mode 100644 src/Generated/New-TitleElement.g.cs delete mode 100644 src/Generated/New-TrElement.g.cs delete mode 100644 src/Generated/New-UElement.g.cs delete mode 100644 src/Generated/New-UlElement.g.cs delete mode 100644 src/Generated/New-VarElement.g.cs delete mode 100644 src/Generated/New-WbrElement.g.cs diff --git a/src/Generated/New-AbbrElement.g.cs b/src/Generated/New-AbbrElement.g.cs deleted file mode 100644 index a5ed9ab..0000000 --- a/src/Generated/New-AbbrElement.g.cs +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// Creates a new abbr element. -/// -[Cmdlet(VerbsCommon.New, "HtmlAbbrElement"), Alias("abbr"), OutputType(typeof(string))] -public class NewAbbrElementCommand(): NewElementCommand("abbr", isVoid: false) {} diff --git a/src/Generated/New-AddressElement.g.cs b/src/Generated/New-AddressElement.g.cs deleted file mode 100644 index fe830cb..0000000 --- a/src/Generated/New-AddressElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new address element. -/// -[Cmdlet(VerbsCommon.New, "HtmlAddressElement"), Alias("address"), OutputType(typeof(string))] -public class NewAddressElementCommand(): NewElementCommand("address", isVoid: false) {} diff --git a/src/Generated/New-ArticleElement.g.cs b/src/Generated/New-ArticleElement.g.cs deleted file mode 100644 index 6e89373..0000000 --- a/src/Generated/New-ArticleElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new article element. -/// -[Cmdlet(VerbsCommon.New, "HtmlArticleElement"), Alias("article"), OutputType(typeof(string))] -public class NewArticleElementCommand(): NewElementCommand("article", isVoid: false) {} diff --git a/src/Generated/New-AsideElement.g.cs b/src/Generated/New-AsideElement.g.cs deleted file mode 100644 index 9e76a03..0000000 --- a/src/Generated/New-AsideElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new aside element. -/// -[Cmdlet(VerbsCommon.New, "HtmlAsideElement"), Alias("aside"), OutputType(typeof(string))] -public class NewAsideElementCommand(): NewElementCommand("aside", isVoid: false) {} diff --git a/src/Generated/New-BElement.g.cs b/src/Generated/New-BElement.g.cs deleted file mode 100644 index 1460c85..0000000 --- a/src/Generated/New-BElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new b element. -/// -[Cmdlet(VerbsCommon.New, "HtmlBElement"), Alias("b"), OutputType(typeof(string))] -public class NewBElementCommand(): NewElementCommand("b", isVoid: false) {} diff --git a/src/Generated/New-BdiElement.g.cs b/src/Generated/New-BdiElement.g.cs deleted file mode 100644 index 1ab6d1f..0000000 --- a/src/Generated/New-BdiElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new bdi element. -/// -[Cmdlet(VerbsCommon.New, "HtmlBdiElement"), Alias("bdi"), OutputType(typeof(string))] -public class NewBdiElementCommand(): NewElementCommand("bdi", isVoid: false) {} diff --git a/src/Generated/New-BdoElement.g.cs b/src/Generated/New-BdoElement.g.cs deleted file mode 100644 index 44a0a1c..0000000 --- a/src/Generated/New-BdoElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new bdo element. -/// -[Cmdlet(VerbsCommon.New, "HtmlBdoElement"), Alias("bdo"), OutputType(typeof(string))] -public class NewBdoElementCommand(): NewElementCommand("bdo", isVoid: false) {} diff --git a/src/Generated/New-BodyElement.g.cs b/src/Generated/New-BodyElement.g.cs deleted file mode 100644 index cfb1cb0..0000000 --- a/src/Generated/New-BodyElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new body element. -/// -[Cmdlet(VerbsCommon.New, "HtmlBodyElement"), Alias("body"), OutputType(typeof(string))] -public class NewBodyElementCommand(): NewElementCommand("body", isVoid: false) {} diff --git a/src/Generated/New-BrElement.g.cs b/src/Generated/New-BrElement.g.cs deleted file mode 100644 index c6beef7..0000000 --- a/src/Generated/New-BrElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new br element. -/// -[Cmdlet(VerbsCommon.New, "HtmlBrElement"), Alias("br"), OutputType(typeof(string))] -public class NewBrElementCommand(): NewElementCommand("br", isVoid: true) {} diff --git a/src/Generated/New-CaptionElement.g.cs b/src/Generated/New-CaptionElement.g.cs deleted file mode 100644 index 99c0088..0000000 --- a/src/Generated/New-CaptionElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new caption element. -/// -[Cmdlet(VerbsCommon.New, "HtmlCaptionElement"), Alias("caption"), OutputType(typeof(string))] -public class NewCaptionElementCommand(): NewElementCommand("caption", isVoid: false) {} diff --git a/src/Generated/New-CiteElement.g.cs b/src/Generated/New-CiteElement.g.cs deleted file mode 100644 index b5450f5..0000000 --- a/src/Generated/New-CiteElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new cite element. -/// -[Cmdlet(VerbsCommon.New, "HtmlCiteElement"), Alias("cite"), OutputType(typeof(string))] -public class NewCiteElementCommand(): NewElementCommand("cite", isVoid: false) {} diff --git a/src/Generated/New-CodeElement.g.cs b/src/Generated/New-CodeElement.g.cs deleted file mode 100644 index a6af442..0000000 --- a/src/Generated/New-CodeElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new code element. -/// -[Cmdlet(VerbsCommon.New, "HtmlCodeElement"), Alias("code"), OutputType(typeof(string))] -public class NewCodeElementCommand(): NewElementCommand("code", isVoid: false) {} diff --git a/src/Generated/New-DatalistElement.g.cs b/src/Generated/New-DatalistElement.g.cs deleted file mode 100644 index 099e56e..0000000 --- a/src/Generated/New-DatalistElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new datalist element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDatalistElement"), Alias("datalist"), OutputType(typeof(string))] -public class NewDatalistElementCommand(): NewElementCommand("datalist", isVoid: false) {} diff --git a/src/Generated/New-DdElement.g.cs b/src/Generated/New-DdElement.g.cs deleted file mode 100644 index 4a5bb8e..0000000 --- a/src/Generated/New-DdElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new dd element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDdElement"), Alias("dd"), OutputType(typeof(string))] -public class NewDdElementCommand(): NewElementCommand("dd", isVoid: false) {} diff --git a/src/Generated/New-DfnElement.g.cs b/src/Generated/New-DfnElement.g.cs deleted file mode 100644 index f3b8cff..0000000 --- a/src/Generated/New-DfnElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new dfn element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDfnElement"), Alias("dfn"), OutputType(typeof(string))] -public class NewDfnElementCommand(): NewElementCommand("dfn", isVoid: false) {} diff --git a/src/Generated/New-DivElement.g.cs b/src/Generated/New-DivElement.g.cs deleted file mode 100644 index 1d1e9d0..0000000 --- a/src/Generated/New-DivElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new div element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDivElement"), Alias("div"), OutputType(typeof(string))] -public class NewDivElementCommand(): NewElementCommand("div", isVoid: false) {} diff --git a/src/Generated/New-DlElement.g.cs b/src/Generated/New-DlElement.g.cs deleted file mode 100644 index de8c9de..0000000 --- a/src/Generated/New-DlElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new dl element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDlElement"), Alias("dl"), OutputType(typeof(string))] -public class NewDlElementCommand(): NewElementCommand("dl", isVoid: false) {} diff --git a/src/Generated/New-DtElement.g.cs b/src/Generated/New-DtElement.g.cs deleted file mode 100644 index 864a3d1..0000000 --- a/src/Generated/New-DtElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new dt element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDtElement"), Alias("dt"), OutputType(typeof(string))] -public class NewDtElementCommand(): NewElementCommand("dt", isVoid: false) {} diff --git a/src/Generated/New-EmElement.g.cs b/src/Generated/New-EmElement.g.cs deleted file mode 100644 index 2e6eb39..0000000 --- a/src/Generated/New-EmElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new em element. -/// -[Cmdlet(VerbsCommon.New, "HtmlEmElement"), Alias("em"), OutputType(typeof(string))] -public class NewEmElementCommand(): NewElementCommand("em", isVoid: false) {} diff --git a/src/Generated/New-FigcaptionElement.g.cs b/src/Generated/New-FigcaptionElement.g.cs deleted file mode 100644 index 899499a..0000000 --- a/src/Generated/New-FigcaptionElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new figcaption element. -/// -[Cmdlet(VerbsCommon.New, "HtmlFigcaptionElement"), Alias("figcaption"), OutputType(typeof(string))] -public class NewFigcaptionElementCommand(): NewElementCommand("figcaption", isVoid: false) {} diff --git a/src/Generated/New-FigureElement.g.cs b/src/Generated/New-FigureElement.g.cs deleted file mode 100644 index 9ee85c7..0000000 --- a/src/Generated/New-FigureElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new figure element. -/// -[Cmdlet(VerbsCommon.New, "HtmlFigureElement"), Alias("figure"), OutputType(typeof(string))] -public class NewFigureElementCommand(): NewElementCommand("figure", isVoid: false) {} diff --git a/src/Generated/New-FooterElement.g.cs b/src/Generated/New-FooterElement.g.cs deleted file mode 100644 index 3af2bbf..0000000 --- a/src/Generated/New-FooterElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new footer element. -/// -[Cmdlet(VerbsCommon.New, "HtmlFooterElement"), Alias("footer"), OutputType(typeof(string))] -public class NewFooterElementCommand(): NewElementCommand("footer", isVoid: false) {} diff --git a/src/Generated/New-H1Element.g.cs b/src/Generated/New-H1Element.g.cs deleted file mode 100644 index 0bf9661..0000000 --- a/src/Generated/New-H1Element.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new h1 element. -/// -[Cmdlet(VerbsCommon.New, "HtmlH1Element"), Alias("h1"), OutputType(typeof(string))] -public class NewH1ElementCommand(): NewElementCommand("h1", isVoid: false) {} diff --git a/src/Generated/New-H2Element.g.cs b/src/Generated/New-H2Element.g.cs deleted file mode 100644 index 7bbd96d..0000000 --- a/src/Generated/New-H2Element.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new h2 element. -/// -[Cmdlet(VerbsCommon.New, "HtmlH2Element"), Alias("h2"), OutputType(typeof(string))] -public class NewH2ElementCommand(): NewElementCommand("h2", isVoid: false) {} diff --git a/src/Generated/New-H3Element.g.cs b/src/Generated/New-H3Element.g.cs deleted file mode 100644 index ebae03e..0000000 --- a/src/Generated/New-H3Element.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new h3 element. -/// -[Cmdlet(VerbsCommon.New, "HtmlH3Element"), Alias("h3"), OutputType(typeof(string))] -public class NewH3ElementCommand(): NewElementCommand("h3", isVoid: false) {} diff --git a/src/Generated/New-H4Element.g.cs b/src/Generated/New-H4Element.g.cs deleted file mode 100644 index a39cec8..0000000 --- a/src/Generated/New-H4Element.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new h4 element. -/// -[Cmdlet(VerbsCommon.New, "HtmlH4Element"), Alias("h4"), OutputType(typeof(string))] -public class NewH4ElementCommand(): NewElementCommand("h4", isVoid: false) {} diff --git a/src/Generated/New-H5Element.g.cs b/src/Generated/New-H5Element.g.cs deleted file mode 100644 index 64d3675..0000000 --- a/src/Generated/New-H5Element.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new h5 element. -/// -[Cmdlet(VerbsCommon.New, "HtmlH5Element"), Alias("h5"), OutputType(typeof(string))] -public class NewH5ElementCommand(): NewElementCommand("h5", isVoid: false) {} diff --git a/src/Generated/New-H6Element.g.cs b/src/Generated/New-H6Element.g.cs deleted file mode 100644 index 013eba2..0000000 --- a/src/Generated/New-H6Element.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new h6 element. -/// -[Cmdlet(VerbsCommon.New, "HtmlH6Element"), Alias("h6"), OutputType(typeof(string))] -public class NewH6ElementCommand(): NewElementCommand("h6", isVoid: false) {} diff --git a/src/Generated/New-HeadElement.g.cs b/src/Generated/New-HeadElement.g.cs deleted file mode 100644 index f6fd9b3..0000000 --- a/src/Generated/New-HeadElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new head element. -/// -[Cmdlet(VerbsCommon.New, "HtmlHeadElement"), Alias("head"), OutputType(typeof(string))] -public class NewHeadElementCommand(): NewElementCommand("head", isVoid: false) {} diff --git a/src/Generated/New-HeaderElement.g.cs b/src/Generated/New-HeaderElement.g.cs deleted file mode 100644 index fa0b4da..0000000 --- a/src/Generated/New-HeaderElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new header element. -/// -[Cmdlet(VerbsCommon.New, "HtmlHeaderElement"), Alias("header"), OutputType(typeof(string))] -public class NewHeaderElementCommand(): NewElementCommand("header", isVoid: false) {} diff --git a/src/Generated/New-HgroupElement.g.cs b/src/Generated/New-HgroupElement.g.cs deleted file mode 100644 index 2d7407a..0000000 --- a/src/Generated/New-HgroupElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new hgroup element. -/// -[Cmdlet(VerbsCommon.New, "HtmlHgroupElement"), Alias("hgroup"), OutputType(typeof(string))] -public class NewHgroupElementCommand(): NewElementCommand("hgroup", isVoid: false) {} diff --git a/src/Generated/New-HrElement.g.cs b/src/Generated/New-HrElement.g.cs deleted file mode 100644 index 679bf56..0000000 --- a/src/Generated/New-HrElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new hr element. -/// -[Cmdlet(VerbsCommon.New, "HtmlHrElement"), Alias("hr"), OutputType(typeof(string))] -public class NewHrElementCommand(): NewElementCommand("hr", isVoid: true) {} diff --git a/src/Generated/New-HtmlElement.g.cs b/src/Generated/New-HtmlElement.g.cs deleted file mode 100644 index 941ea4c..0000000 --- a/src/Generated/New-HtmlElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new html element. -/// -[Cmdlet(VerbsCommon.New, "HtmlHtmlElement"), Alias("html"), OutputType(typeof(string))] -public class NewHtmlElementCommand(): NewElementCommand("html", isVoid: false) {} diff --git a/src/Generated/New-IElement.g.cs b/src/Generated/New-IElement.g.cs deleted file mode 100644 index 7727276..0000000 --- a/src/Generated/New-IElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new i element. -/// -[Cmdlet(VerbsCommon.New, "HtmlIElement"), Alias("i"), OutputType(typeof(string))] -public class NewIElementCommand(): NewElementCommand("i", isVoid: false) {} diff --git a/src/Generated/New-KbdElement.g.cs b/src/Generated/New-KbdElement.g.cs deleted file mode 100644 index 17732c7..0000000 --- a/src/Generated/New-KbdElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new kbd element. -/// -[Cmdlet(VerbsCommon.New, "HtmlKbdElement"), Alias("kbd"), OutputType(typeof(string))] -public class NewKbdElementCommand(): NewElementCommand("kbd", isVoid: false) {} diff --git a/src/Generated/New-LegendElement.g.cs b/src/Generated/New-LegendElement.g.cs deleted file mode 100644 index 1801213..0000000 --- a/src/Generated/New-LegendElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new legend element. -/// -[Cmdlet(VerbsCommon.New, "HtmlLegendElement"), Alias("legend"), OutputType(typeof(string))] -public class NewLegendElementCommand(): NewElementCommand("legend", isVoid: false) {} diff --git a/src/Generated/New-MainElement.g.cs b/src/Generated/New-MainElement.g.cs deleted file mode 100644 index 73e3c39..0000000 --- a/src/Generated/New-MainElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new main element. -/// -[Cmdlet(VerbsCommon.New, "HtmlMainElement"), Alias("main"), OutputType(typeof(string))] -public class NewMainElementCommand(): NewElementCommand("main", isVoid: false) {} diff --git a/src/Generated/New-MarkElement.g.cs b/src/Generated/New-MarkElement.g.cs deleted file mode 100644 index 17cfb7d..0000000 --- a/src/Generated/New-MarkElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new mark element. -/// -[Cmdlet(VerbsCommon.New, "HtmlMarkElement"), Alias("mark"), OutputType(typeof(string))] -public class NewMarkElementCommand(): NewElementCommand("mark", isVoid: false) {} diff --git a/src/Generated/New-MenuElement.g.cs b/src/Generated/New-MenuElement.g.cs deleted file mode 100644 index 7b05e0d..0000000 --- a/src/Generated/New-MenuElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new menu element. -/// -[Cmdlet(VerbsCommon.New, "HtmlMenuElement"), Alias("menu"), OutputType(typeof(string))] -public class NewMenuElementCommand(): NewElementCommand("menu", isVoid: false) {} diff --git a/src/Generated/New-NavElement.g.cs b/src/Generated/New-NavElement.g.cs deleted file mode 100644 index 8c92049..0000000 --- a/src/Generated/New-NavElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new nav element. -/// -[Cmdlet(VerbsCommon.New, "HtmlNavElement"), Alias("nav"), OutputType(typeof(string))] -public class NewNavElementCommand(): NewElementCommand("nav", isVoid: false) {} diff --git a/src/Generated/New-NoscriptElement.g.cs b/src/Generated/New-NoscriptElement.g.cs deleted file mode 100644 index d252508..0000000 --- a/src/Generated/New-NoscriptElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new noscript element. -/// -[Cmdlet(VerbsCommon.New, "HtmlNoscriptElement"), Alias("noscript"), OutputType(typeof(string))] -public class NewNoscriptElementCommand(): NewElementCommand("noscript", isVoid: false) {} diff --git a/src/Generated/New-PElement.g.cs b/src/Generated/New-PElement.g.cs deleted file mode 100644 index bcf82d1..0000000 --- a/src/Generated/New-PElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new p element. -/// -[Cmdlet(VerbsCommon.New, "HtmlPElement"), Alias("p"), OutputType(typeof(string))] -public class NewPElementCommand(): NewElementCommand("p", isVoid: false) {} diff --git a/src/Generated/New-PictureElement.g.cs b/src/Generated/New-PictureElement.g.cs deleted file mode 100644 index d0a7c47..0000000 --- a/src/Generated/New-PictureElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new picture element. -/// -[Cmdlet(VerbsCommon.New, "HtmlPictureElement"), Alias("picture"), OutputType(typeof(string))] -public class NewPictureElementCommand(): NewElementCommand("picture", isVoid: false) {} diff --git a/src/Generated/New-PreElement.g.cs b/src/Generated/New-PreElement.g.cs deleted file mode 100644 index 774fb3f..0000000 --- a/src/Generated/New-PreElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new pre element. -/// -[Cmdlet(VerbsCommon.New, "HtmlPreElement"), Alias("pre"), OutputType(typeof(string))] -public class NewPreElementCommand(): NewElementCommand("pre", isVoid: false) {} diff --git a/src/Generated/New-RpElement.g.cs b/src/Generated/New-RpElement.g.cs deleted file mode 100644 index 5555cbe..0000000 --- a/src/Generated/New-RpElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new rp element. -/// -[Cmdlet(VerbsCommon.New, "HtmlRpElement"), Alias("rpTag"), OutputType(typeof(string))] -public class NewRpElementCommand(): NewElementCommand("rp", isVoid: false) {} diff --git a/src/Generated/New-RtElement.g.cs b/src/Generated/New-RtElement.g.cs deleted file mode 100644 index d0a47bd..0000000 --- a/src/Generated/New-RtElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new rt element. -/// -[Cmdlet(VerbsCommon.New, "HtmlRtElement"), Alias("rt"), OutputType(typeof(string))] -public class NewRtElementCommand(): NewElementCommand("rt", isVoid: false) {} diff --git a/src/Generated/New-RubyElement.g.cs b/src/Generated/New-RubyElement.g.cs deleted file mode 100644 index c364ed0..0000000 --- a/src/Generated/New-RubyElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new ruby element. -/// -[Cmdlet(VerbsCommon.New, "HtmlRubyElement"), Alias("ruby"), OutputType(typeof(string))] -public class NewRubyElementCommand(): NewElementCommand("ruby", isVoid: false) {} diff --git a/src/Generated/New-SElement.g.cs b/src/Generated/New-SElement.g.cs deleted file mode 100644 index 6d4bbda..0000000 --- a/src/Generated/New-SElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new s element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSElement"), Alias("s"), OutputType(typeof(string))] -public class NewSElementCommand(): NewElementCommand("s", isVoid: false) {} diff --git a/src/Generated/New-SampElement.g.cs b/src/Generated/New-SampElement.g.cs deleted file mode 100644 index f17cc01..0000000 --- a/src/Generated/New-SampElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new samp element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSampElement"), Alias("samp"), OutputType(typeof(string))] -public class NewSampElementCommand(): NewElementCommand("samp", isVoid: false) {} diff --git a/src/Generated/New-SearchElement.g.cs b/src/Generated/New-SearchElement.g.cs deleted file mode 100644 index a078aac..0000000 --- a/src/Generated/New-SearchElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new search element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSearchElement"), Alias("search"), OutputType(typeof(string))] -public class NewSearchElementCommand(): NewElementCommand("search", isVoid: false) {} diff --git a/src/Generated/New-SectionElement.g.cs b/src/Generated/New-SectionElement.g.cs deleted file mode 100644 index 906b28c..0000000 --- a/src/Generated/New-SectionElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new section element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSectionElement"), Alias("section"), OutputType(typeof(string))] -public class NewSectionElementCommand(): NewElementCommand("section", isVoid: false) {} diff --git a/src/Generated/New-SmallElement.g.cs b/src/Generated/New-SmallElement.g.cs deleted file mode 100644 index ecfd905..0000000 --- a/src/Generated/New-SmallElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new small element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSmallElement"), Alias("small"), OutputType(typeof(string))] -public class NewSmallElementCommand(): NewElementCommand("small", isVoid: false) {} diff --git a/src/Generated/New-SpanElement.g.cs b/src/Generated/New-SpanElement.g.cs deleted file mode 100644 index 087a261..0000000 --- a/src/Generated/New-SpanElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new span element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSpanElement"), Alias("span"), OutputType(typeof(string))] -public class NewSpanElementCommand(): NewElementCommand("span", isVoid: false) {} diff --git a/src/Generated/New-StrongElement.g.cs b/src/Generated/New-StrongElement.g.cs deleted file mode 100644 index 811982f..0000000 --- a/src/Generated/New-StrongElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new strong element. -/// -[Cmdlet(VerbsCommon.New, "HtmlStrongElement"), Alias("strong"), OutputType(typeof(string))] -public class NewStrongElementCommand(): NewElementCommand("strong", isVoid: false) {} diff --git a/src/Generated/New-SubElement.g.cs b/src/Generated/New-SubElement.g.cs deleted file mode 100644 index 528683c..0000000 --- a/src/Generated/New-SubElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new sub element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSubElement"), Alias("sub"), OutputType(typeof(string))] -public class NewSubElementCommand(): NewElementCommand("sub", isVoid: false) {} diff --git a/src/Generated/New-SummaryElement.g.cs b/src/Generated/New-SummaryElement.g.cs deleted file mode 100644 index f7a6789..0000000 --- a/src/Generated/New-SummaryElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new summary element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSummaryElement"), Alias("summary"), OutputType(typeof(string))] -public class NewSummaryElementCommand(): NewElementCommand("summary", isVoid: false) {} diff --git a/src/Generated/New-SupElement.g.cs b/src/Generated/New-SupElement.g.cs deleted file mode 100644 index 546ca97..0000000 --- a/src/Generated/New-SupElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new sup element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSupElement"), Alias("sup"), OutputType(typeof(string))] -public class NewSupElementCommand(): NewElementCommand("sup", isVoid: false) {} diff --git a/src/Generated/New-TableElement.g.cs b/src/Generated/New-TableElement.g.cs deleted file mode 100644 index 819fc37..0000000 --- a/src/Generated/New-TableElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new table element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTableElement"), Alias("table"), OutputType(typeof(string))] -public class NewTableElementCommand(): NewElementCommand("table", isVoid: false) {} diff --git a/src/Generated/New-TbodyElement.g.cs b/src/Generated/New-TbodyElement.g.cs deleted file mode 100644 index 114ccb9..0000000 --- a/src/Generated/New-TbodyElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new tbody element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTbodyElement"), Alias("tbody"), OutputType(typeof(string))] -public class NewTbodyElementCommand(): NewElementCommand("tbody", isVoid: false) {} diff --git a/src/Generated/New-TfootElement.g.cs b/src/Generated/New-TfootElement.g.cs deleted file mode 100644 index 60b46a0..0000000 --- a/src/Generated/New-TfootElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new tfoot element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTfootElement"), Alias("tfoot"), OutputType(typeof(string))] -public class NewTfootElementCommand(): NewElementCommand("tfoot", isVoid: false) {} diff --git a/src/Generated/New-TheadElement.g.cs b/src/Generated/New-TheadElement.g.cs deleted file mode 100644 index fd5f6ec..0000000 --- a/src/Generated/New-TheadElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new thead element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTheadElement"), Alias("thead"), OutputType(typeof(string))] -public class NewTheadElementCommand(): NewElementCommand("thead", isVoid: false) {} diff --git a/src/Generated/New-TitleElement.g.cs b/src/Generated/New-TitleElement.g.cs deleted file mode 100644 index a5fba7d..0000000 --- a/src/Generated/New-TitleElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new title element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTitleElement"), Alias("title"), OutputType(typeof(string))] -public class NewTitleElementCommand(): NewElementCommand("title", isVoid: false) {} diff --git a/src/Generated/New-TrElement.g.cs b/src/Generated/New-TrElement.g.cs deleted file mode 100644 index 00ad013..0000000 --- a/src/Generated/New-TrElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new tr element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTrElement"), Alias("tr"), OutputType(typeof(string))] -public class NewTrElementCommand(): NewElementCommand("tr", isVoid: false) {} diff --git a/src/Generated/New-UElement.g.cs b/src/Generated/New-UElement.g.cs deleted file mode 100644 index 9f788fe..0000000 --- a/src/Generated/New-UElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new u element. -/// -[Cmdlet(VerbsCommon.New, "HtmlUElement"), Alias("u"), OutputType(typeof(string))] -public class NewUElementCommand(): NewElementCommand("u", isVoid: false) {} diff --git a/src/Generated/New-UlElement.g.cs b/src/Generated/New-UlElement.g.cs deleted file mode 100644 index 4bcb65e..0000000 --- a/src/Generated/New-UlElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new ul element. -/// -[Cmdlet(VerbsCommon.New, "HtmlUlElement"), Alias("ul"), OutputType(typeof(string))] -public class NewUlElementCommand(): NewElementCommand("ul", isVoid: false) {} diff --git a/src/Generated/New-VarElement.g.cs b/src/Generated/New-VarElement.g.cs deleted file mode 100644 index 99f1fe6..0000000 --- a/src/Generated/New-VarElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new var element. -/// -[Cmdlet(VerbsCommon.New, "HtmlVarElement"), Alias("var"), OutputType(typeof(string))] -public class NewVarElementCommand(): NewElementCommand("var", isVoid: false) {} diff --git a/src/Generated/New-WbrElement.g.cs b/src/Generated/New-WbrElement.g.cs deleted file mode 100644 index 55c62ec..0000000 --- a/src/Generated/New-WbrElement.g.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new wbr element. -/// -[Cmdlet(VerbsCommon.New, "HtmlWbrElement"), Alias("wbr"), OutputType(typeof(string))] -public class NewWbrElementCommand(): NewElementCommand("wbr", isVoid: true) {} From cffbc813707ccc15c7b375b2859a5f33d03f5df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 12:59:07 +0200 Subject: [PATCH 12/23] Rename the file extension of the cmdlets [skip ci] --- src/Elements/New-AElement.cs | 51 --- src/Elements/New-AElement.psm1 | 56 ++++ src/Elements/New-AreaElement.cs | 78 ----- src/Elements/New-AreaElement.psm1 | 87 +++++ src/Elements/New-AudioElement.cs | 72 ----- src/Elements/New-AudioElement.psm1 | 82 +++++ src/Elements/New-BaseElement.cs | 30 -- src/Elements/New-BaseElement.psm1 | 32 ++ src/Elements/New-BlockquoteElement.cs | 23 -- src/Elements/New-BlockquoteElement.psm1 | 24 ++ src/Elements/New-ButtonElement.cs | 116 ------- src/Elements/New-ButtonElement.psm1 | 134 ++++++++ src/Elements/New-CanvasElement.cs | 32 -- src/Elements/New-CanvasElement.psm1 | 34 ++ src/Elements/New-ColElement.cs | 25 -- src/Elements/New-ColElement.psm1 | 26 ++ src/Elements/New-ColGroupElement.cs | 25 -- src/Elements/New-ColGroupElement.psm1 | 26 ++ src/Elements/New-DataElement.cs | 23 -- src/Elements/New-DataElement.psm1 | 24 ++ ...{New-DelElement.cs => New-DelElement.psm1} | 40 +-- src/Elements/New-DetailsElement.cs | 30 -- src/Elements/New-DetailsElement.psm1 | 32 ++ src/Elements/New-DialogElement.cs | 30 -- src/Elements/New-DialogElement.psm1 | 33 ++ src/Elements/New-EmbedElement.cs | 46 --- src/Elements/New-EmbedElement.psm1 | 50 +++ src/Elements/New-FieldsetElement.cs | 37 --- src/Elements/New-FieldsetElement.psm1 | 40 +++ src/Elements/New-FormElement.cs | 74 ----- src/Elements/New-FormElement.psm1 | 85 +++++ src/Elements/New-IframeElement.cs | 77 ----- src/Elements/New-IframeElement.psm1 | 87 +++++ src/Elements/New-ImgElement.cs | 81 ----- src/Elements/New-ImgElement.psm1 | 91 ++++++ src/Elements/New-InputElement.cs | 265 --------------- src/Elements/New-InputElement.psm1 | 303 ++++++++++++++++++ ...{New-InsElement.cs => New-InsElement.psm1} | 40 +-- src/Elements/New-LabelElement.cs | 23 -- src/Elements/New-LabelElement.psm1 | 24 ++ src/Elements/New-LiElement.cs | 25 -- src/Elements/New-LiElement.psm1 | 26 ++ src/Elements/New-LinkElement.cs | 72 ----- src/Elements/New-LinkElement.psm1 | 81 +++++ src/Elements/New-MapElement.cs | 23 -- src/Elements/New-MapElement.psm1 | 24 ++ src/Elements/New-MetaElement.cs | 55 ---- src/Elements/New-MetaElement.psm1 | 59 ++++ src/Elements/New-MeterElement.cs | 60 ---- src/Elements/New-MeterElement.psm1 | 66 ++++ src/Elements/New-ObjectElement.cs | 60 ---- src/Elements/New-ObjectElement.psm1 | 66 ++++ src/Elements/New-OlElement.cs | 39 --- src/Elements/New-OlElement.psm1 | 43 +++ src/Elements/New-OptgroupElement.cs | 30 -- src/Elements/New-OptgroupElement.psm1 | 32 ++ src/Elements/New-OptionElement.cs | 44 --- src/Elements/New-OptionElement.psm1 | 48 +++ src/Elements/New-OutputElement.cs | 37 --- src/Elements/New-OutputElement.psm1 | 40 +++ src/Elements/New-ProgressElement.cs | 32 -- src/Elements/New-ProgressElement.psm1 | 34 ++ src/Elements/New-QElement.cs | 23 -- src/Elements/New-QElement.psm1 | 24 ++ src/Elements/New-ScriptElement.cs | 58 ---- src/Elements/New-ScriptElement.psm1 | 65 ++++ src/Elements/New-SelectElement.cs | 67 ---- src/Elements/New-SelectElement.psm1 | 74 +++++ src/Elements/New-SlotElement.cs | 23 -- src/Elements/New-SlotElement.psm1 | 24 ++ src/Elements/New-SourceElement.cs | 75 ----- src/Elements/New-SourceElement.psm1 | 82 +++++ src/Elements/New-StyleElement.cs | 23 -- src/Elements/New-StyleElement.psm1 | 24 ++ src/Elements/New-TdElement.cs | 39 --- src/Elements/New-TdElement.psm1 | 42 +++ src/Elements/New-TemplateElement.cs | 44 --- src/Elements/New-TemplateElement.psm1 | 49 +++ src/Elements/New-TextareaElement.cs | 116 ------- src/Elements/New-TextareaElement.psm1 | 132 ++++++++ src/Elements/New-ThElement.cs | 53 --- src/Elements/New-ThElement.psm1 | 59 ++++ ...ew-TimeElement.cs => New-TimeElement.psm1} | 29 +- src/Elements/New-TrackElement.cs | 53 --- src/Elements/New-TrackElement.psm1 | 59 ++++ src/Elements/New-VideoElement.cs | 109 ------- src/Elements/New-VideoElement.psm1 | 124 +++++++ 87 files changed, 2604 insertions(+), 2350 deletions(-) delete mode 100644 src/Elements/New-AElement.cs create mode 100644 src/Elements/New-AElement.psm1 delete mode 100644 src/Elements/New-AreaElement.cs create mode 100644 src/Elements/New-AreaElement.psm1 delete mode 100644 src/Elements/New-AudioElement.cs create mode 100644 src/Elements/New-AudioElement.psm1 delete mode 100644 src/Elements/New-BaseElement.cs create mode 100644 src/Elements/New-BaseElement.psm1 delete mode 100644 src/Elements/New-BlockquoteElement.cs create mode 100644 src/Elements/New-BlockquoteElement.psm1 delete mode 100644 src/Elements/New-ButtonElement.cs create mode 100644 src/Elements/New-ButtonElement.psm1 delete mode 100644 src/Elements/New-CanvasElement.cs create mode 100644 src/Elements/New-CanvasElement.psm1 delete mode 100644 src/Elements/New-ColElement.cs create mode 100644 src/Elements/New-ColElement.psm1 delete mode 100644 src/Elements/New-ColGroupElement.cs create mode 100644 src/Elements/New-ColGroupElement.psm1 delete mode 100644 src/Elements/New-DataElement.cs create mode 100644 src/Elements/New-DataElement.psm1 rename src/Elements/{New-DelElement.cs => New-DelElement.psm1} (58%) delete mode 100644 src/Elements/New-DetailsElement.cs create mode 100644 src/Elements/New-DetailsElement.psm1 delete mode 100644 src/Elements/New-DialogElement.cs create mode 100644 src/Elements/New-DialogElement.psm1 delete mode 100644 src/Elements/New-EmbedElement.cs create mode 100644 src/Elements/New-EmbedElement.psm1 delete mode 100644 src/Elements/New-FieldsetElement.cs create mode 100644 src/Elements/New-FieldsetElement.psm1 delete mode 100644 src/Elements/New-FormElement.cs create mode 100644 src/Elements/New-FormElement.psm1 delete mode 100644 src/Elements/New-IframeElement.cs create mode 100644 src/Elements/New-IframeElement.psm1 delete mode 100644 src/Elements/New-ImgElement.cs create mode 100644 src/Elements/New-ImgElement.psm1 delete mode 100644 src/Elements/New-InputElement.cs create mode 100644 src/Elements/New-InputElement.psm1 rename src/Elements/{New-InsElement.cs => New-InsElement.psm1} (58%) delete mode 100644 src/Elements/New-LabelElement.cs create mode 100644 src/Elements/New-LabelElement.psm1 delete mode 100644 src/Elements/New-LiElement.cs create mode 100644 src/Elements/New-LiElement.psm1 delete mode 100644 src/Elements/New-LinkElement.cs create mode 100644 src/Elements/New-LinkElement.psm1 delete mode 100644 src/Elements/New-MapElement.cs create mode 100644 src/Elements/New-MapElement.psm1 delete mode 100644 src/Elements/New-MetaElement.cs create mode 100644 src/Elements/New-MetaElement.psm1 delete mode 100644 src/Elements/New-MeterElement.cs create mode 100644 src/Elements/New-MeterElement.psm1 delete mode 100644 src/Elements/New-ObjectElement.cs create mode 100644 src/Elements/New-ObjectElement.psm1 delete mode 100644 src/Elements/New-OlElement.cs create mode 100644 src/Elements/New-OlElement.psm1 delete mode 100644 src/Elements/New-OptgroupElement.cs create mode 100644 src/Elements/New-OptgroupElement.psm1 delete mode 100644 src/Elements/New-OptionElement.cs create mode 100644 src/Elements/New-OptionElement.psm1 delete mode 100644 src/Elements/New-OutputElement.cs create mode 100644 src/Elements/New-OutputElement.psm1 delete mode 100644 src/Elements/New-ProgressElement.cs create mode 100644 src/Elements/New-ProgressElement.psm1 delete mode 100644 src/Elements/New-QElement.cs create mode 100644 src/Elements/New-QElement.psm1 delete mode 100644 src/Elements/New-ScriptElement.cs create mode 100644 src/Elements/New-ScriptElement.psm1 delete mode 100644 src/Elements/New-SelectElement.cs create mode 100644 src/Elements/New-SelectElement.psm1 delete mode 100644 src/Elements/New-SlotElement.cs create mode 100644 src/Elements/New-SlotElement.psm1 delete mode 100644 src/Elements/New-SourceElement.cs create mode 100644 src/Elements/New-SourceElement.psm1 delete mode 100644 src/Elements/New-StyleElement.cs create mode 100644 src/Elements/New-StyleElement.psm1 delete mode 100644 src/Elements/New-TdElement.cs create mode 100644 src/Elements/New-TdElement.psm1 delete mode 100644 src/Elements/New-TemplateElement.cs create mode 100644 src/Elements/New-TemplateElement.psm1 delete mode 100644 src/Elements/New-TextareaElement.cs create mode 100644 src/Elements/New-TextareaElement.psm1 delete mode 100644 src/Elements/New-ThElement.cs create mode 100644 src/Elements/New-ThElement.psm1 rename src/Elements/{New-TimeElement.cs => New-TimeElement.psm1} (66%) delete mode 100644 src/Elements/New-TrackElement.cs create mode 100644 src/Elements/New-TrackElement.psm1 delete mode 100644 src/Elements/New-VideoElement.cs create mode 100644 src/Elements/New-VideoElement.psm1 diff --git a/src/Elements/New-AElement.cs b/src/Elements/New-AElement.cs deleted file mode 100644 index 4176b0e..0000000 --- a/src/Elements/New-AElement.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new a element. -/// -[Cmdlet(VerbsCommon.New, "HtmlAElement"), Alias("a"), OutputType(typeof(string))] -public class NewAElementCommand(): NewElementCommand("a", isVoid: false) { - - /// - /// The suggested filename when the browser treats the linked URL as a download. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Download { get; set; } - - /// - /// The URL that the hyperlink points to. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Href { get; set; } - - /// - /// A list of URLs. When the link is followed, the browser will send POST requests with the body PING to the URLs. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri[] Ping { get; set; } = []; - - /// - /// The relationship of the linked URL. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Rel { get; set; } = []; - - /// - /// The browsing context to show the results of navigation. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Target { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["href"] = Href.ToString(); - if (!string.IsNullOrWhiteSpace(Download)) attributes["download"] = Download; - if (Ping.Length > 0) attributes["ping"] = string.Join(' ', Ping.Select(url => url.ToString())).Trim(); - if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); - if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; - } -} diff --git a/src/Elements/New-AElement.psm1 b/src/Elements/New-AElement.psm1 new file mode 100644 index 0000000..64a8610 --- /dev/null +++ b/src/Elements/New-AElement.psm1 @@ -0,0 +1,56 @@ +<# +.SYNOPSIS + Creates a new `a` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlAElement"), Alias("a"), OutputType(typeof(string))] +function New-HtmlAElementCommand(): NewElementCommand("a", isVoid: false) { + + <# + .SYNOPSIS + The suggested filename when the browser treats the linked URL as a download. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Download + + <# + .SYNOPSIS + The URL that the hyperlink points to. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [uri] $Href + + <# + .SYNOPSIS + A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [uri[]] $Ping = []; + + <# + .SYNOPSIS + The relationship of the linked URL. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Rel = []; + + <# + .SYNOPSIS + The browsing context to show the results of navigation. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Target + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["href"] = Href.ToString(); + if (!string.IsNullOrWhiteSpace(Download)) attributes["download"] = Download; + if (Ping.Length > 0) attributes["ping"] = string.Join(' ', Ping.Select(url => url.ToString())).Trim(); + if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); + if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + } +} diff --git a/src/Elements/New-AreaElement.cs b/src/Elements/New-AreaElement.cs deleted file mode 100644 index 1092468..0000000 --- a/src/Elements/New-AreaElement.cs +++ /dev/null @@ -1,78 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new area element. -/// -[Cmdlet(VerbsCommon.New, "HtmlAreaElement"), Alias("area"), OutputType(typeof(string))] -public class NewAreaElementCommand(): NewElementCommand("area", isVoid: true) { - - /// - /// A text to display on browsers that do not display images. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Alt { get; set; } - - /// - /// The browsing context to show the results of navigation. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateCount(3, int.MaxValue)] - public double[]? Coords { get; set; } - - /// - /// The suggested filename when the browser treats the linked URL as a download. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Download { get; set; } - - /// - /// The hyperlink target for the area. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Href { get; set; } - - /// - /// A list of URLs. When the link is followed, the browser will send POST requests with the body PING to the URLs. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri[] Ping { get; set; } = []; - - /// - /// The relationship of the linked URL. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Rel { get; set; } = []; - - /// - /// The browsing context to show the results of navigation. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("circle", "default", "poly", "rect")] - public string? Shape { get; set; } - - /// - /// The browsing context to show the results of navigation. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Target { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["href"] = Href.ToString(); - - if (Shape is not null) { - attributes["shape"] = Shape; - if (Coords is not null && Shape != "default") attributes["coords"] = string.Join(',', Coords.Select(number => number.ToString(CultureInfo.InvariantCulture))); - } - - if (Alt is not null) attributes["alt"] = Alt; - if (!string.IsNullOrWhiteSpace(Download)) attributes["download"] = Download; - if (Ping.Length > 0) attributes["ping"] = string.Join(' ', Ping.Select(url => url.ToString())).Trim(); - if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); - if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; - } -} diff --git a/src/Elements/New-AreaElement.psm1 b/src/Elements/New-AreaElement.psm1 new file mode 100644 index 0000000..f34b4f1 --- /dev/null +++ b/src/Elements/New-AreaElement.psm1 @@ -0,0 +1,87 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `area` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlAreaElement"), Alias("area"), OutputType(typeof(string))] +function New-HtmlAreaElementCommand(): NewElementCommand("area", isVoid: true) { + + <# + .SYNOPSIS + A text to display on browsers that do not display images. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Alt + + <# + .SYNOPSIS + The browsing context to show the results of navigation. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateCount(3, int.MaxValue)] + double[]? Coords + + <# + .SYNOPSIS + The suggested filename when the browser treats the linked URL as a download. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Download + + <# + .SYNOPSIS + The hyperlink target for the area. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [uri] $Href + + <# + .SYNOPSIS + A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [uri[]] $Ping = []; + + <# + .SYNOPSIS + The relationship of the linked URL. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Rel = []; + + <# + .SYNOPSIS + The browsing context to show the results of navigation. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("circle", "default", "poly", "rect")] + [string] $Shape + + <# + .SYNOPSIS + The browsing context to show the results of navigation. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Target + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["href"] = Href.ToString(); + + if (Shape is not null) { + attributes["shape"] = Shape; + if (Coords is not null && Shape != "default") attributes["coords"] = string.Join(',', Coords.Select(number => number.ToString(CultureInfo.InvariantCulture))); + } + + if (Alt is not null) attributes["alt"] = Alt; + if (!string.IsNullOrWhiteSpace(Download)) attributes["download"] = Download; + if (Ping.Length > 0) attributes["ping"] = string.Join(' ', Ping.Select(url => url.ToString())).Trim(); + if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); + if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + } +} diff --git a/src/Elements/New-AudioElement.cs b/src/Elements/New-AudioElement.cs deleted file mode 100644 index cb578df..0000000 --- a/src/Elements/New-AudioElement.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new audio element. -/// -[Cmdlet(VerbsCommon.New, "HtmlAudioElement"), Alias("audio"), OutputType(typeof(string))] -public class NewAudioElementCommand(): NewElementCommand("audio", isVoid: false) { - - /// - /// Value indicating whether playback should start automatically as soon as the audio signal allows. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter AutoPlay { get; set; } - - /// - /// Value indicating whether to offer controls to allow the user to control audio playback. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Controls { get; set; } - - /// - /// Value indicating whether CORS must be used when fetching the resource. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("anonymous", "use-credentials")] - public string? CrossOrigin { get; set; } - - /// - /// Value indicating whether to disable the capability of remote playback in devices that are attached using wired and wireless technologies. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter DisableRemotePlayback { get; set; } - - /// - /// Value indicating whether the audio player will automatically seek back to the start upon reaching the end of the audio. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Loop { get; set; } - - /// - /// Value indicating whether the audio will be initially silenced. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Muted { get; set; } - - /// - /// Value providing a hint to the browser about what the author thinks will lead to the best user experience. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("auto", "none", "metadata")] - public string? Preload { get; set; } - - /// - /// The URL of the audio to embed. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Src { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (AutoPlay) attributes["autoplay"] = true; - if (Controls) attributes["controls"] = true; - if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (DisableRemotePlayback) attributes["disableremoteplayback"] = true; - if (Loop) attributes["loop"] = true; - if (Muted) attributes["muted"] = true; - if (Preload is not null) attributes["preload"] = Preload; - if (Src is not null) attributes["src"] = Src.ToString(); - } -} diff --git a/src/Elements/New-AudioElement.psm1 b/src/Elements/New-AudioElement.psm1 new file mode 100644 index 0000000..a5d90ef --- /dev/null +++ b/src/Elements/New-AudioElement.psm1 @@ -0,0 +1,82 @@ +<# +.SYNOPSIS + Creates a new `audio` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlAudioElement"), Alias("audio"), OutputType(typeof(string))] +function New-HtmlAudioElementCommand(): NewElementCommand("audio", isVoid: false) { + + <# + .SYNOPSIS + Value indicating whether playback should start automatically as soon as the audio signal allows. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $AutoPlay + + <# + .SYNOPSIS + Value indicating whether to offer controls to allow the user to control audio playback. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Controls + + <# + .SYNOPSIS + Value indicating whether CORS must be used when fetching the resource. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("anonymous", "use-credentials")] + [string] $CrossOrigin + + <# + .SYNOPSIS + Value indicating whether to disable the capability of remote playback in devices that are attached using wired and wireless technologies. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $DisableRemotePlayback + + <# + .SYNOPSIS + Value indicating whether the audio player will automatically seek back to the start upon reaching the end of the audio. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Loop + + <# + .SYNOPSIS + Value indicating whether the audio will be initially silenced. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Muted + + <# + .SYNOPSIS + Value providing a hint to the browser about what the author thinks will lead to the best user experience. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("auto", "none", "metadata")] + [string] $Preload + + <# + .SYNOPSIS + The URL of the audio to embed. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Src + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (AutoPlay) attributes["autoplay"] = true; + if (Controls) attributes["controls"] = true; + if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; + if (DisableRemotePlayback) attributes["disableremoteplayback"] = true; + if (Loop) attributes["loop"] = true; + if (Muted) attributes["muted"] = true; + if (Preload is not null) attributes["preload"] = Preload; + if (Src is not null) attributes["src"] = Src.ToString(); + } +} diff --git a/src/Elements/New-BaseElement.cs b/src/Elements/New-BaseElement.cs deleted file mode 100644 index 43d53bc..0000000 --- a/src/Elements/New-BaseElement.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new base element. -/// -[Cmdlet(VerbsCommon.New, "HtmlBaseElement"), Alias("base"), OutputType(typeof(string))] -public class NewBaseElementCommand(): NewElementCommand("base", isVoid: true) { - - /// - /// The base URL to be used throughout the document for relative URLs. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Href { get; set; } - - /// - /// The default browsing context to show the results of navigation from elements without explicit target attribute. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Target { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["href"] = Href.ToString(); - if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; - } -} diff --git a/src/Elements/New-BaseElement.psm1 b/src/Elements/New-BaseElement.psm1 new file mode 100644 index 0000000..a32e53d --- /dev/null +++ b/src/Elements/New-BaseElement.psm1 @@ -0,0 +1,32 @@ +<# +.SYNOPSIS + Creates a new `base` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlBaseElement"), Alias("base"), OutputType(typeof(string))] +function New-HtmlBaseElementCommand(): NewElementCommand("base", isVoid: true) { + + <# + .SYNOPSIS + The base URL to be used throughout the document for relative URLs. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [uri] $Href + + <# + .SYNOPSIS + The default browsing context to show the results of navigation from elements without explicit `target` attribute. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Target + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["href"] = Href.ToString(); + if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + } +} diff --git a/src/Elements/New-BlockquoteElement.cs b/src/Elements/New-BlockquoteElement.cs deleted file mode 100644 index fc97231..0000000 --- a/src/Elements/New-BlockquoteElement.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new blockquote element. -/// -[Cmdlet(VerbsCommon.New, "HtmlBlockquoteElement"), Alias("blockquote"), OutputType(typeof(string))] -public class NewBlockquoteElementCommand(): NewElementCommand("blockquote", isVoid: false) { - - /// - /// A URL that designates a source document or message for the information quoted. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Cite { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Cite is not null) attributes["cite"] = Cite.ToString(); - } -} diff --git a/src/Elements/New-BlockquoteElement.psm1 b/src/Elements/New-BlockquoteElement.psm1 new file mode 100644 index 0000000..0db5b77 --- /dev/null +++ b/src/Elements/New-BlockquoteElement.psm1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Creates a new `blockquote` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlBlockquoteElement"), Alias("blockquote"), OutputType(typeof(string))] +function New-HtmlBlockquoteElementCommand(): NewElementCommand("blockquote", isVoid: false) { + + <# + .SYNOPSIS + A URL that designates a source document or message for the information quoted. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Cite + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Cite is not null) attributes["cite"] = Cite.ToString(); + } +} diff --git a/src/Elements/New-ButtonElement.cs b/src/Elements/New-ButtonElement.cs deleted file mode 100644 index c0e61c8..0000000 --- a/src/Elements/New-ButtonElement.cs +++ /dev/null @@ -1,116 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Net.Mime; - -/// -/// Creates a new button element. -/// -[Cmdlet(VerbsCommon.New, "HtmlButtonElement"), Alias("button"), OutputType(typeof(string))] -public class NewButtonElementCommand(): NewElementCommand("button", isVoid: false) { - - /// - /// The action to be performed on an element being controlled via the attribute. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Command { get; set; } - - /// - /// The identifier of an element to control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? CommandFor { get; set; } - - /// - /// Value indicating whether to prevent the user from interacting with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Disabled { get; set; } - - /// - /// The identifier of a form element to associate with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Form { get; set; } - - /// - /// The URL that processes the information submitted by the button. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? FormAction { get; set; } - - /// - /// Value indicating how to encode the form data that is submitted. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] - public string? FormEnctype { get; set; } - - /// - /// The HTTP method used to submit the form. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("dialog", "get", "post")] - public string? FormMethod { get; set; } - - /// - /// Value indicating whether the form is not to be validated when it is submitted. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter FormNoValidate { get; set; } - - /// - /// The browsing context to show the response after submitting the form. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? FormTarget { get; set; } - - /// - /// The name of the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// The identifier of a popover element to control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? PopoverTarget { get; set; } - - /// - /// The action to be performed on a popover element being controlled via the attribute. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("hide", "show", "toggle")] - public string? PopoverTargetAction { get; set; } - - /// - /// The default behavior of the button. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("button", "reset", "submit")] - public string? Type { get; set; } - - /// - /// The value of the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public object? Value { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Command)) attributes["command"] = Command; - if (!string.IsNullOrWhiteSpace(CommandFor)) attributes["commandfor"] = CommandFor; - if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (FormAction is not null) attributes["formaction"] = FormAction.ToString(); - if (FormEnctype is not null) attributes["formenctype"] = FormEnctype; - if (FormMethod is not null) attributes["formmethod"] = FormMethod; - if (FormNoValidate) attributes["formnovalidate"] = true; - if (!string.IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (!string.IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; - if (PopoverTargetAction is not null) attributes["popovertargetaction"] = PopoverTargetAction; - if (Type is not null) attributes["type"] = Type; - if (Value is not null) attributes["value"] = Value; - } -} diff --git a/src/Elements/New-ButtonElement.psm1 b/src/Elements/New-ButtonElement.psm1 new file mode 100644 index 0000000..9cb54d8 --- /dev/null +++ b/src/Elements/New-ButtonElement.psm1 @@ -0,0 +1,134 @@ +using System.Net.Mime; + +<# +.SYNOPSIS + Creates a new `button` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlButtonElement"), Alias("button"), OutputType(typeof(string))] +function New-HtmlButtonElementCommand(): NewElementCommand("button", isVoid: false) { + + <# + .SYNOPSIS + The action to be performed on an element being controlled via the attribute. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Command + + <# + .SYNOPSIS + The identifier of an element to control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $CommandFor + + <# + .SYNOPSIS + Value indicating whether to prevent the user from interacting with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Disabled + + <# + .SYNOPSIS + The identifier of a `form` element to associate with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Form + + <# + .SYNOPSIS + The URL that processes the information submitted by the button. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? FormAction + + <# + .SYNOPSIS + Value indicating how to encode the form data that is submitted. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] + [string] $FormEnctype + + <# + .SYNOPSIS + The HTTP method used to submit the form. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("dialog", "get", "post")] + [string] $FormMethod + + <# + .SYNOPSIS + Value indicating whether the form is not to be validated when it is submitted. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $FormNoValidate + + <# + .SYNOPSIS + The browsing context to show the response after submitting the form. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $FormTarget + + <# + .SYNOPSIS + The name of the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + The identifier of a popover element to control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $PopoverTarget + + <# + .SYNOPSIS + The action to be performed on a popover element being controlled via the attribute. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("hide", "show", "toggle")] + [string] $PopoverTargetAction + + <# + .SYNOPSIS + The default behavior of the button. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("button", "reset", "submit")] + [string] $Type + + <# + .SYNOPSIS + The value of the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [object] $Value + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(Command)) attributes["command"] = Command; + if (!string.IsNullOrWhiteSpace(CommandFor)) attributes["commandfor"] = CommandFor; + if (Disabled) attributes["disabled"] = true; + if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (FormAction is not null) attributes["formaction"] = FormAction.ToString(); + if (FormEnctype is not null) attributes["formenctype"] = FormEnctype; + if (FormMethod is not null) attributes["formmethod"] = FormMethod; + if (FormNoValidate) attributes["formnovalidate"] = true; + if (!string.IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (!string.IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; + if (PopoverTargetAction is not null) attributes["popovertargetaction"] = PopoverTargetAction; + if (Type is not null) attributes["type"] = Type; + if (Value is not null) attributes["value"] = Value; + } +} diff --git a/src/Elements/New-CanvasElement.cs b/src/Elements/New-CanvasElement.cs deleted file mode 100644 index 46610e2..0000000 --- a/src/Elements/New-CanvasElement.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new canvas element. -/// -[Cmdlet(VerbsCommon.New, "HtmlCanvasElement"), Alias("canvas"), OutputType(typeof(string))] -public class NewCanvasElementCommand(): NewElementCommand("canvas", isVoid: false) { - - /// - /// The height of the coordinate space in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Height { get; set; } = -1; - - /// - /// The width of the coordinate space in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Width { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-CanvasElement.psm1 b/src/Elements/New-CanvasElement.psm1 new file mode 100644 index 0000000..1363dbd --- /dev/null +++ b/src/Elements/New-CanvasElement.psm1 @@ -0,0 +1,34 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `canvas` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlCanvasElement"), Alias("canvas"), OutputType(typeof(string))] +function New-HtmlCanvasElementCommand(): NewElementCommand("canvas", isVoid: false) { + + <# + .SYNOPSIS + The height of the coordinate space in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Height = -1; + + <# + .SYNOPSIS + The width of the coordinate space in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Width = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-ColElement.cs b/src/Elements/New-ColElement.cs deleted file mode 100644 index e683cab..0000000 --- a/src/Elements/New-ColElement.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new col element. -/// -[Cmdlet(VerbsCommon.New, "HtmlColElement"), Alias("col"), OutputType(typeof(string))] -public class NewColElementCommand(): NewElementCommand("col", isVoid: true) { - - /// - /// The number of consecutive columns the element spans. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.Positive)] - public int Span { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Span > 0) attributes["span"] = Span.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-ColElement.psm1 b/src/Elements/New-ColElement.psm1 new file mode 100644 index 0000000..ef3e0b9 --- /dev/null +++ b/src/Elements/New-ColElement.psm1 @@ -0,0 +1,26 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `col` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlColElement"), Alias("col"), OutputType(typeof(string))] +function New-HtmlColElementCommand(): NewElementCommand("col", isVoid: true) { + + <# + .SYNOPSIS + The number of consecutive columns the element spans. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + int Span + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Span > 0) attributes["span"] = Span.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-ColGroupElement.cs b/src/Elements/New-ColGroupElement.cs deleted file mode 100644 index b9b4361..0000000 --- a/src/Elements/New-ColGroupElement.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new colgroup element. -/// -[Cmdlet(VerbsCommon.New, "HtmlColgroupElement"), Alias("colgroup"), OutputType(typeof(string))] -public class NewColgroupElementCommand(): NewElementCommand("colgroup", isVoid: false) { - - /// - /// The number of consecutive columns the element spans. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.Positive)] - public int Span { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Span > 0) attributes["span"] = Span.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-ColGroupElement.psm1 b/src/Elements/New-ColGroupElement.psm1 new file mode 100644 index 0000000..5faeec5 --- /dev/null +++ b/src/Elements/New-ColGroupElement.psm1 @@ -0,0 +1,26 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `colgroup` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlColgroupElement"), Alias("colgroup"), OutputType(typeof(string))] +function New-HtmlColgroupElementCommand(): NewElementCommand("colgroup", isVoid: false) { + + <# + .SYNOPSIS + The number of consecutive columns the element spans. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + int Span + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Span > 0) attributes["span"] = Span.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-DataElement.cs b/src/Elements/New-DataElement.cs deleted file mode 100644 index 16327d9..0000000 --- a/src/Elements/New-DataElement.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new data element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDataElement"), Alias("dataTag"), OutputType(typeof(string))] -public class NewDataElementCommand(): NewElementCommand("data", isVoid: false) { - - /// - /// The machine-readable translation of the content of the element. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required string Value { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["value"] = Value; - } -} diff --git a/src/Elements/New-DataElement.psm1 b/src/Elements/New-DataElement.psm1 new file mode 100644 index 0000000..34266f7 --- /dev/null +++ b/src/Elements/New-DataElement.psm1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Creates a new `data` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlDataElement"), Alias("dataTag"), OutputType(typeof(string))] +function New-HtmlDataElementCommand(): NewElementCommand("data", isVoid: false) { + + <# + .SYNOPSIS + The machine-readable translation of the content of the element. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required string Value + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["value"] = Value; + } +} diff --git a/src/Elements/New-DelElement.cs b/src/Elements/New-DelElement.psm1 similarity index 58% rename from src/Elements/New-DelElement.cs rename to src/Elements/New-DelElement.psm1 index 4aba228..913671f 100644 --- a/src/Elements/New-DelElement.cs +++ b/src/Elements/New-DelElement.psm1 @@ -1,26 +1,28 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new del element. -/// +<# +.SYNOPSIS + Creates a new `del` element. +#> [Cmdlet(VerbsCommon.New, "HtmlDelElement"), Alias("delTag"), OutputType(typeof(string))] -public class NewDelElementCommand(): NewElementCommand("del", isVoid: false) { +function New-HtmlDelElementCommand(): NewElementCommand("del", isVoid: false) { - /// - /// A URI for a resource that explains the change. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Cite { get; set; } + <# + .SYNOPSIS + A URI for a resource that explains the change. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Cite - /// - /// The date and time of the change. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public object? DateTime { get; set; } + <# + .SYNOPSIS + The date and time of the change. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [object] $DateTime - /// - /// Populates the specified attribute collection with the element attributes. - /// + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); diff --git a/src/Elements/New-DetailsElement.cs b/src/Elements/New-DetailsElement.cs deleted file mode 100644 index 0c37a8b..0000000 --- a/src/Elements/New-DetailsElement.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new details element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDetailsElement"), Alias("details"), OutputType(typeof(string))] -public class NewDetailsElementCommand(): NewElementCommand("details", isVoid: false) { - - /// - /// The group name allowing multiple details elements to be connected, with only one open at a time. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// Value indicating whether the details are currently visible. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Open { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Open) attributes["open"] = true; - } -} diff --git a/src/Elements/New-DetailsElement.psm1 b/src/Elements/New-DetailsElement.psm1 new file mode 100644 index 0000000..332dabc --- /dev/null +++ b/src/Elements/New-DetailsElement.psm1 @@ -0,0 +1,32 @@ +<# +.SYNOPSIS + Creates a new `details` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlDetailsElement"), Alias("details"), OutputType(typeof(string))] +function New-HtmlDetailsElementCommand(): NewElementCommand("details", isVoid: false) { + + <# + .SYNOPSIS + The group name allowing multiple `details` elements to be connected, with only one open at a time. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + Value indicating whether the details are currently visible. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Open + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (Open) attributes["open"] = true; + } +} diff --git a/src/Elements/New-DialogElement.cs b/src/Elements/New-DialogElement.cs deleted file mode 100644 index 5d774cb..0000000 --- a/src/Elements/New-DialogElement.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new dialog element. -/// -[Cmdlet(VerbsCommon.New, "HtmlDialogElement"), Alias("dialog"), OutputType(typeof(string))] -public class NewDialogElementCommand(): NewElementCommand("dialog", isVoid: false) { - - /// - /// Specifies the types of user actions that can be used to close the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("any", "closerequest", "none")] - public string? ClosedBy { get; set; } - - /// - /// Value indicating whether the dialog box is active and is available for interaction. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Open { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (ClosedBy is not null) attributes["closedby"] = ClosedBy; - if (Open) attributes["open"] = true; - } -} diff --git a/src/Elements/New-DialogElement.psm1 b/src/Elements/New-DialogElement.psm1 new file mode 100644 index 0000000..1674796 --- /dev/null +++ b/src/Elements/New-DialogElement.psm1 @@ -0,0 +1,33 @@ +<# +.SYNOPSIS + Creates a new `dialog` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlDialogElement"), Alias("dialog"), OutputType(typeof(string))] +function New-HtmlDialogElementCommand(): NewElementCommand("dialog", isVoid: false) { + + <# + .SYNOPSIS + Specifies the types of user actions that can be used to close the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("any", "closerequest", "none")] + [string] $ClosedBy + + <# + .SYNOPSIS + Value indicating whether the dialog box is active and is available for interaction. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Open + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (ClosedBy is not null) attributes["closedby"] = ClosedBy; + if (Open) attributes["open"] = true; + } +} diff --git a/src/Elements/New-EmbedElement.cs b/src/Elements/New-EmbedElement.cs deleted file mode 100644 index 88f4eae..0000000 --- a/src/Elements/New-EmbedElement.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new embed element. -/// -[Cmdlet(VerbsCommon.New, "HtmlEmbedElement"), Alias("embed"), OutputType(typeof(string))] -public class NewEmbedElementCommand(): NewElementCommand("embed", isVoid: true) { - - /// - /// The displayed height of the resource, in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Height { get; set; } = -1; - - /// - /// The URL of the resource being embedded. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Src { get; set; } - - /// - /// The media type to use, optionally including a codecs parameter. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required string Type { get; set; } - - /// - /// The displayed height of the resource, in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Width { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["src"] = Src.ToString(); - attributes["type"] = Type; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-EmbedElement.psm1 b/src/Elements/New-EmbedElement.psm1 new file mode 100644 index 0000000..5b43493 --- /dev/null +++ b/src/Elements/New-EmbedElement.psm1 @@ -0,0 +1,50 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `embed` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlEmbedElement"), Alias("embed"), OutputType(typeof(string))] +function New-HtmlEmbedElementCommand(): NewElementCommand("embed", isVoid: true) { + + <# + .SYNOPSIS + The displayed height of the resource, in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Height = -1; + + <# + .SYNOPSIS + The URL of the resource being embedded. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required Uri Src + + <# + .SYNOPSIS + The media type to use, optionally including a `codecs` parameter. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required string Type + + <# + .SYNOPSIS + The displayed height of the resource, in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Width = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["src"] = Src.ToString(); + attributes["type"] = Type; + if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-FieldsetElement.cs b/src/Elements/New-FieldsetElement.cs deleted file mode 100644 index 6e54138..0000000 --- a/src/Elements/New-FieldsetElement.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new fieldset element. -/// -[Cmdlet(VerbsCommon.New, "HtmlFieldsetElement"), Alias("fieldset"), OutputType(typeof(string))] -public class NewFieldsetElementCommand(): NewElementCommand("fieldset", isVoid: false) { - - /// - /// Value indicating whether all form controls that are descendants of the element, are disabled. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Disabled { get; set; } - - /// - /// The identifier of a form element to associate with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Form { get; set; } - - /// - /// The name associated with the group. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - } -} diff --git a/src/Elements/New-FieldsetElement.psm1 b/src/Elements/New-FieldsetElement.psm1 new file mode 100644 index 0000000..23b2313 --- /dev/null +++ b/src/Elements/New-FieldsetElement.psm1 @@ -0,0 +1,40 @@ +<# +.SYNOPSIS + Creates a new `fieldset` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlFieldsetElement"), Alias("fieldset"), OutputType(typeof(string))] +function New-HtmlFieldsetElementCommand(): NewElementCommand("fieldset", isVoid: false) { + + <# + .SYNOPSIS + Value indicating whether all form controls that are descendants of the element, are disabled. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Disabled + + <# + .SYNOPSIS + The identifier of a `form` element to associate with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Form + + <# + .SYNOPSIS + The name associated with the group. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Disabled) attributes["disabled"] = true; + if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + } +} diff --git a/src/Elements/New-FormElement.cs b/src/Elements/New-FormElement.cs deleted file mode 100644 index a229044..0000000 --- a/src/Elements/New-FormElement.cs +++ /dev/null @@ -1,74 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Net.Mime; - -/// -/// Creates a new form element. -/// -[Cmdlet(VerbsCommon.New, "HtmlFormElement"), Alias("form"), OutputType(typeof(string))] -public class NewFormElementCommand(): NewElementCommand("form", isVoid: false) { - - /// - /// The URL that processes the form submission. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Action { get; set; } - - /// - /// Value indicating whether input elements can by default have their values automatically completed by the browser. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("off", "on")] - public string? AutoComplete { get; set; } - - /// - /// The media type of the form submission. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] - public string? Enctype { get; set; } - - /// - /// The HTTP method to submit the form with. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("dialog", "get", "post")] - public string? Method { get; set; } - - /// - /// The name of the form. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// Value indicating whether the form shouldn't be validated when submitted. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter NoValidate { get; set; } - - /// - /// The annotations and what kinds of links the form creates. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Rel { get; set; } = []; - - /// - /// The browsing context to show the response after submitting the form. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Target { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Action is not null) attributes["action"] = Action.ToString(); - if (AutoComplete is not null) attributes["autocomplete"] = AutoComplete; - if (Enctype is not null) attributes["enctype"] = Enctype; - if (Method is not null) attributes["method"] = Method; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (NoValidate) attributes["novalidate"] = true; - if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); - if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; - } -} diff --git a/src/Elements/New-FormElement.psm1 b/src/Elements/New-FormElement.psm1 new file mode 100644 index 0000000..038685f --- /dev/null +++ b/src/Elements/New-FormElement.psm1 @@ -0,0 +1,85 @@ +using System.Net.Mime; + +<# +.SYNOPSIS + Creates a new `form` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlFormElement"), Alias("form"), OutputType(typeof(string))] +function New-HtmlFormElementCommand(): NewElementCommand("form", isVoid: false) { + + <# + .SYNOPSIS + The URL that processes the form submission. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Action + + <# + .SYNOPSIS + Value indicating whether input elements can by default have their values automatically completed by the browser. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("off", "on")] + [string] $AutoComplete + + <# + .SYNOPSIS + The media type of the form submission. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] + [string] $Enctype + + <# + .SYNOPSIS + The HTTP method to submit the form with. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("dialog", "get", "post")] + [string] $Method + + <# + .SYNOPSIS + The name of the form. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + Value indicating whether the form shouldn't be validated when submitted. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $NoValidate + + <# + .SYNOPSIS + The annotations and what kinds of links the form creates. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Rel = []; + + <# + .SYNOPSIS + The browsing context to show the response after submitting the form. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Target + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Action is not null) attributes["action"] = Action.ToString(); + if (AutoComplete is not null) attributes["autocomplete"] = AutoComplete; + if (Enctype is not null) attributes["enctype"] = Enctype; + if (Method is not null) attributes["method"] = Method; + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (NoValidate) attributes["novalidate"] = true; + if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); + if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + } +} diff --git a/src/Elements/New-IframeElement.cs b/src/Elements/New-IframeElement.cs deleted file mode 100644 index 55c7491..0000000 --- a/src/Elements/New-IframeElement.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new iframe element. -/// -[Cmdlet(VerbsCommon.New, "HtmlIframeElement"), Alias("iframe"), OutputType(typeof(string))] -public class NewIframeElementCommand(): NewElementCommand("iframe", isVoid: false) { - - /// - /// Specifies a permissions policy thaht defines what features are available to the frame based on the origin of the request. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Allow { get; set; } - - /// - /// The height of the frame in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Height { get; set; } = -1; - - /// - /// Value indicating how the browser should load the frame. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("eager", "lazy")] - public string? Loading { get; set; } - - /// - /// A targetable name for the embedded browsing context. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// Value indicating which referrer to send when fetching the frame's resource. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet( - "no-referrer-when-downgrade", "no-referrer", "origin-when-cross-origin", "origin", - "same-origin", "strict-origin-when-cross-origin", "strict-origin", "unsafe-url" - )] - public string? ReferrerPolicy { get; set; } - - /// - /// The restrictions applied to the content embedded in the frame. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Sandbox { get; set; } = []; - - /// - /// The URL of the page to embed. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Src { get; set; } - - /// - /// The width of the frame in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Width { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["src"] = Src.ToString(); - if (!string.IsNullOrWhiteSpace(Allow)) attributes["allow"] = Allow; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (Loading is not null) attributes["loading"] = Loading; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (ReferrerPolicy is not null) attributes["referrerpolicy"] = ReferrerPolicy; - if (Sandbox.Length > 0) attributes["sandbox"] = string.Join(' ', Sandbox).Trim(); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-IframeElement.psm1 b/src/Elements/New-IframeElement.psm1 new file mode 100644 index 0000000..520dbe5 --- /dev/null +++ b/src/Elements/New-IframeElement.psm1 @@ -0,0 +1,87 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `iframe` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlIframeElement"), Alias("iframe"), OutputType(typeof(string))] +function New-HtmlIframeElementCommand(): NewElementCommand("iframe", isVoid: false) { + + <# + .SYNOPSIS + Specifies a permissions policy thaht defines what features are available to the frame based on the origin of the request. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Allow + + <# + .SYNOPSIS + The height of the frame in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Height = -1; + + <# + .SYNOPSIS + Value indicating how the browser should load the frame. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("eager", "lazy")] + [string] $Loading + + <# + .SYNOPSIS + A targetable name for the embedded browsing context. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + Value indicating which referrer to send when fetching the frame's resource. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet( + "no-referrer-when-downgrade", "no-referrer", "origin-when-cross-origin", "origin", + "same-origin", "strict-origin-when-cross-origin", "strict-origin", "unsafe-url" + )] + [string] $ReferrerPolicy + + <# + .SYNOPSIS + The restrictions applied to the content embedded in the frame. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Sandbox = []; + + <# + .SYNOPSIS + The URL of the page to embed. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required Uri Src + + <# + .SYNOPSIS + The width of the frame in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Width = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["src"] = Src.ToString(); + if (!string.IsNullOrWhiteSpace(Allow)) attributes["allow"] = Allow; + if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (Loading is not null) attributes["loading"] = Loading; + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (ReferrerPolicy is not null) attributes["referrerpolicy"] = ReferrerPolicy; + if (Sandbox.Length > 0) attributes["sandbox"] = string.Join(' ', Sandbox).Trim(); + if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-ImgElement.cs b/src/Elements/New-ImgElement.cs deleted file mode 100644 index 57122ce..0000000 --- a/src/Elements/New-ImgElement.cs +++ /dev/null @@ -1,81 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new img element. -/// -[Cmdlet(VerbsCommon.New, "HtmlImgElement"), Alias("img"), OutputType(typeof(string))] -public class NewImgElementCommand(): NewElementCommand("img", isVoid: true) { - - /// - /// A text to display on browsers that do not display images. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Alt { get; set; } - - /// - /// The intrinsic height of the image, in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Height { get; set; } = -1; - - /// - /// Value indicating whether the image is part of a server-side map. - /// - [Parameter] - public SwitchParameter IsMap { get; set; } - - /// - /// Value indicating how the browser should load the image. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("eager", "lazy")] - public string? Loading { get; set; } - - /// - /// The intended display sizes of the image. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Sizes { get; set; } = []; - - /// - /// The image URL. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Src { get; set; } - - /// - /// The possible image sources for the user agent to use. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] SrcSet { get; set; } = []; - - /// - /// The partial URL (starting with #) of an image map associated with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? UseMap { get; set; } - - /// - /// The intrinsic width of the image, in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Width { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["src"] = Src.ToString(); - if (Alt is not null) attributes["alt"] = Alt; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (IsMap) attributes["ismap"] = true; - if (Loading is not null) attributes["loading"] = Loading; - if (Sizes.Length > 0) attributes["sizes"] = string.Join(", ", Sizes); - if (SrcSet.Length > 0) attributes["srcset"] = string.Join(", ", SrcSet); - if (!string.IsNullOrWhiteSpace(UseMap)) attributes["usemap"] = UseMap.StartsWith('#') ? UseMap : $"#{UseMap}"; - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-ImgElement.psm1 b/src/Elements/New-ImgElement.psm1 new file mode 100644 index 0000000..80f390e --- /dev/null +++ b/src/Elements/New-ImgElement.psm1 @@ -0,0 +1,91 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `img` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlImgElement"), Alias("img"), OutputType(typeof(string))] +function New-HtmlImgElementCommand(): NewElementCommand("img", isVoid: true) { + + <# + .SYNOPSIS + A text to display on browsers that do not display images. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Alt + + <# + .SYNOPSIS + The intrinsic height of the image, in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Height = -1; + + <# + .SYNOPSIS + Value indicating whether the image is part of a server-side map. + #> + [Parameter] + [switch] $IsMap + + <# + .SYNOPSIS + Value indicating how the browser should load the image. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("eager", "lazy")] + [string] $Loading + + <# + .SYNOPSIS + The intended display sizes of the image. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Sizes = []; + + <# + .SYNOPSIS + The image URL. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required Uri Src + + <# + .SYNOPSIS + The possible image sources for the user agent to use. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $SrcSet = []; + + <# + .SYNOPSIS + The partial URL (starting with `#`) of an image map associated with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $UseMap + + <# + .SYNOPSIS + The intrinsic width of the image, in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Width = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["src"] = Src.ToString(); + if (Alt is not null) attributes["alt"] = Alt; + if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (IsMap) attributes["ismap"] = true; + if (Loading is not null) attributes["loading"] = Loading; + if (Sizes.Length > 0) attributes["sizes"] = string.Join(", ", Sizes); + if (SrcSet.Length > 0) attributes["srcset"] = string.Join(", ", SrcSet); + if (!string.IsNullOrWhiteSpace(UseMap)) attributes["usemap"] = UseMap.StartsWith('#') ? UseMap : $"#{UseMap}"; + if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-InputElement.cs b/src/Elements/New-InputElement.cs deleted file mode 100644 index 3c64022..0000000 --- a/src/Elements/New-InputElement.cs +++ /dev/null @@ -1,265 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; -using System.Net.Mime; -using System.Text.RegularExpressions; - -/// -/// Creates a new input element. -/// -[Cmdlet(VerbsCommon.New, "HtmlInputElement"), Alias("input"), OutputType(typeof(string))] -public class NewInputElementCommand(): NewElementCommand("input", isVoid: true) { - - /// - /// Defines which file types are selectable in a file upload control. - /// Valid for the file input type only. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Accept { get; set; } - - /// - /// A text to display on browsers that do not display images. - /// Valid for the image input type only. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Alt { get; set; } - - /// - /// A hint for a user agent's autocomplete feature. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] AutoComplete { get; set; } = []; - - /// - /// Value indicating which camera to use for capture of image or video data. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("environment", "user")] - public string? Capture { get; set; } - - /// - /// Value indicating whether the checkbox is checked or the radio button is the currently selected one. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Checked { get; set; } - - /// - /// The field name to use for sending the element's directionality in form submission. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? DirName { get; set; } - - /// - /// Value indicating whether to prevent the user from interacting with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Disabled { get; set; } - - /// - /// The identifier of a form element to associate with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Form { get; set; } - - /// - /// The URL that processes the information submitted by the button. - /// Valid for the image and submit input types only. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? FormAction { get; set; } - - /// - /// Value indicating how to encode the form data that is submitted. - /// Valid for the image and submit input types only. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] - public string? FormEnctype { get; set; } - - /// - /// The HTTP method used to submit the form. - /// Valid for the image and submit input types only. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("dialog", "get", "post")] - public string? FormMethod { get; set; } - - /// - /// Value indicating whether the form is not to be validated when it is submitted. - /// Valid for the image and submit input types only. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter FormNoValidate { get; set; } - - /// - /// The browsing context to show the response after submitting the form. - /// Valid for the image and submit input types only. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? FormTarget { get; set; } - - /// - /// The intrinsic height of the image, in CSS pixels. - /// Valid for the image input type only. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Height { get; set; } = -1; - - /// - /// The identifier of a datalist element located in the same document.. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? List { get; set; } - - /// - /// The greatest value in the range of permitted values. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public string? Max { get; set; } - - /// - /// The maximum string length that the user can enter. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int MaxLength { get; set; } = -1; - - /// - /// The lowest value in the range of permitted values. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public string? Min { get; set; } - - /// - /// The minimum string length required that the user should enter. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int MinLength { get; set; } = -1; - - /// - /// Value indicating whether the user can enter comma separated email addresses in the email widget or can choose more than one file with the file input. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Multiple { get; set; } - - /// - /// The name of the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// The regular expression that the must match in order for the value to pass constraint validation. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Regex? Pattern { get; set; } - - /// - /// A hint to the user of what can be entered in the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Placeholder { get; set; } - - /// - /// The identifier of a popover element to control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? PopoverTarget { get; set; } - - /// - /// The action to be performed on a popover element being controlled via the attribute. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("hide", "show", "toggle")] - public string? PopoverTargetAction { get; set; } - - /// - /// Value indicating whether the user cannot modify the value of the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter ReadOnly { get; set; } - - /// - /// Value indicating whether the user must fill in a value before submitting a form. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Required { get; set; } - - /// - /// Value indicating how much of the input is shown. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.Positive)] - public int Size { get; set; } - - /// - /// The URL of the image file to display to represent the graphical button. - /// Valid for the image input type only. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Src { get; set; } - - /// - /// A number that specifies the granularity that the value must adhere to, or the special value any. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public string? Step { get; set; } - - /// - /// The type of control to render. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet( - "button", "checkbox", "color", "date", "datetime-local", "email", - "file", "hidden", "image", "month", "number", "password", - "radio", "range", "reset", "search", "submit", "tel", - "text", "time", "url", "week" - )] - public string? Type { get; set; } - - /// - /// The value of the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public object? Value { get; set; } - - /// - /// The intrinsic width of the image, in CSS pixels. - /// Valid for the image input type only. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Width { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Accept)) attributes["accept"] = Accept; - if (Alt is not null) attributes["alt"] = Alt; - if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); - if (Capture is not null) attributes["capture"] = Capture; - if (Checked) attributes["checked"] = true; - if (!string.IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; - if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (FormAction is not null) attributes["formaction"] = FormAction.ToString(); - if (FormEnctype is not null) attributes["formenctype"] = FormEnctype; - if (FormMethod is not null) attributes["formmethod"] = FormMethod; - if (FormNoValidate) attributes["formnovalidate"] = true; - if (!string.IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(List)) attributes["list"] = List; - if (!string.IsNullOrWhiteSpace(Max)) attributes["max"] = Max; - if (MaxLength >= 0) attributes["maxlength"] = MaxLength.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Min)) attributes["min"] = Min; - if (MinLength >= 0) attributes["minlength"] = MinLength.ToString(CultureInfo.InvariantCulture); - if (Multiple) attributes["multiple"] = true; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Pattern is not null) attributes["pattern"] = Pattern.ToString().Replace(@"\", @"\\"); - if (!string.IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; - if (!string.IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; - if (PopoverTargetAction is not null) attributes["popovertargetaction"] = PopoverTargetAction; - if (ReadOnly) attributes["readonly"] = true; - if (Required) attributes["required"] = true; - if (Size > 0) attributes["size"] = Size.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Step)) attributes["step"] = Step; - if (Type is not null) attributes["type"] = Type; - if (Value is not null) attributes["value"] = Value; - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-InputElement.psm1 b/src/Elements/New-InputElement.psm1 new file mode 100644 index 0000000..b589a1f --- /dev/null +++ b/src/Elements/New-InputElement.psm1 @@ -0,0 +1,303 @@ +using System.Globalization; +using System.Net.Mime; +using System.Text.RegularExpressions; + +<# +.SYNOPSIS + Creates a new `input` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlInputElement"), Alias("input"), OutputType(typeof(string))] +function New-HtmlInputElementCommand(): NewElementCommand("input", isVoid: true) { + + <# + .SYNOPSIS + Defines which file types are selectable in a file upload control. + /// Valid for the `file` input type only. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Accept + + <# + .SYNOPSIS + A text to display on browsers that do not display images. + /// Valid for the `image` input type only. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Alt + + <# + .SYNOPSIS + A hint for a user agent's autocomplete feature. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $AutoComplete = []; + + <# + .SYNOPSIS + Value indicating which camera to use for capture of image or video data. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("environment", "user")] + [string] $Capture + + <# + .SYNOPSIS + Value indicating whether the checkbox is checked or the radio button is the currently selected one. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Checked + + <# + .SYNOPSIS + The field name to use for sending the element's directionality in form submission. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $DirName + + <# + .SYNOPSIS + Value indicating whether to prevent the user from interacting with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Disabled + + <# + .SYNOPSIS + The identifier of a `form` element to associate with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Form + + <# + .SYNOPSIS + The URL that processes the information submitted by the button. + /// Valid for the `image` and `submit` input types only. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? FormAction + + <# + .SYNOPSIS + Value indicating how to encode the form data that is submitted. + /// Valid for the `image` and `submit` input types only. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] + [string] $FormEnctype + + <# + .SYNOPSIS + The HTTP method used to submit the form. + /// Valid for the `image` and `submit` input types only. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("dialog", "get", "post")] + [string] $FormMethod + + <# + .SYNOPSIS + Value indicating whether the form is not to be validated when it is submitted. + /// Valid for the `image` and `submit` input types only. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $FormNoValidate + + <# + .SYNOPSIS + The browsing context to show the response after submitting the form. + /// Valid for the `image` and `submit` input types only. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $FormTarget + + <# + .SYNOPSIS + The intrinsic height of the image, in CSS pixels. + /// Valid for the `image` input type only. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Height = -1; + + <# + .SYNOPSIS + The identifier of a `datalist` element located in the same document.. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $List + + <# + .SYNOPSIS + The greatest value in the range of permitted values. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [string] $Max + + <# + .SYNOPSIS + The maximum string length that the user can enter. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int MaxLength = -1; + + <# + .SYNOPSIS + The lowest value in the range of permitted values. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [string] $Min + + <# + .SYNOPSIS + The minimum string length required that the user should enter. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int MinLength = -1; + + <# + .SYNOPSIS + Value indicating whether the user can enter comma separated email addresses in the `email` widget or can choose more than one file with the `file` input. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Multiple + + <# + .SYNOPSIS + The name of the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + The regular expression that the must match in order for the value to pass constraint validation. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Regex? Pattern + + <# + .SYNOPSIS + A hint to the user of what can be entered in the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Placeholder + + <# + .SYNOPSIS + The identifier of a popover element to control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $PopoverTarget + + <# + .SYNOPSIS + The action to be performed on a popover element being controlled via the attribute. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("hide", "show", "toggle")] + [string] $PopoverTargetAction + + <# + .SYNOPSIS + Value indicating whether the user cannot modify the value of the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $ReadOnly + + <# + .SYNOPSIS + Value indicating whether the user must fill in a value before submitting a form. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Required + + <# + .SYNOPSIS + Value indicating how much of the input is shown. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + int Size + + <# + .SYNOPSIS + The URL of the image file to display to represent the graphical button. + /// Valid for the `image` input type only. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Src + + <# + .SYNOPSIS + A number that specifies the granularity that the value must adhere to, or the special value `any`. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [string] $Step + + <# + .SYNOPSIS + The type of control to render. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet( + "button", "checkbox", "color", "date", "datetime-local", "email", + "file", "hidden", "image", "month", "number", "password", + "radio", "range", "reset", "search", "submit", "tel", + "text", "time", "url", "week" + )] + [string] $Type + + <# + .SYNOPSIS + The value of the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [object] $Value + + <# + .SYNOPSIS + The intrinsic width of the image, in CSS pixels. + /// Valid for the `image` input type only. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Width = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(Accept)) attributes["accept"] = Accept; + if (Alt is not null) attributes["alt"] = Alt; + if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); + if (Capture is not null) attributes["capture"] = Capture; + if (Checked) attributes["checked"] = true; + if (!string.IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; + if (Disabled) attributes["disabled"] = true; + if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (FormAction is not null) attributes["formaction"] = FormAction.ToString(); + if (FormEnctype is not null) attributes["formenctype"] = FormEnctype; + if (FormMethod is not null) attributes["formmethod"] = FormMethod; + if (FormNoValidate) attributes["formnovalidate"] = true; + if (!string.IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; + if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (!string.IsNullOrWhiteSpace(List)) attributes["list"] = List; + if (!string.IsNullOrWhiteSpace(Max)) attributes["max"] = Max; + if (MaxLength >= 0) attributes["maxlength"] = MaxLength.ToString(CultureInfo.InvariantCulture); + if (!string.IsNullOrWhiteSpace(Min)) attributes["min"] = Min; + if (MinLength >= 0) attributes["minlength"] = MinLength.ToString(CultureInfo.InvariantCulture); + if (Multiple) attributes["multiple"] = true; + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (Pattern is not null) attributes["pattern"] = Pattern.ToString().Replace(@"\", @"\\"); + if (!string.IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; + if (!string.IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; + if (PopoverTargetAction is not null) attributes["popovertargetaction"] = PopoverTargetAction; + if (ReadOnly) attributes["readonly"] = true; + if (Required) attributes["required"] = true; + if (Size > 0) attributes["size"] = Size.ToString(CultureInfo.InvariantCulture); + if (!string.IsNullOrWhiteSpace(Step)) attributes["step"] = Step; + if (Type is not null) attributes["type"] = Type; + if (Value is not null) attributes["value"] = Value; + if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-InsElement.cs b/src/Elements/New-InsElement.psm1 similarity index 58% rename from src/Elements/New-InsElement.cs rename to src/Elements/New-InsElement.psm1 index c344bb8..398871d 100644 --- a/src/Elements/New-InsElement.cs +++ b/src/Elements/New-InsElement.psm1 @@ -1,26 +1,28 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new ins element. -/// +<# +.SYNOPSIS + Creates a new `ins` element. +#> [Cmdlet(VerbsCommon.New, "HtmlInsElement"), Alias("ins"), OutputType(typeof(string))] -public class NewInsElementCommand(): NewElementCommand("ins", isVoid: false) { +function New-HtmlInsElementCommand(): NewElementCommand("ins", isVoid: false) { - /// - /// A URI for a resource that explains the change. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Cite { get; set; } + <# + .SYNOPSIS + A URI for a resource that explains the change. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Cite - /// - /// The date and time of the change. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public object? DateTime { get; set; } + <# + .SYNOPSIS + The date and time of the change. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [object] $DateTime - /// - /// Populates the specified attribute collection with the element attributes. - /// + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); diff --git a/src/Elements/New-LabelElement.cs b/src/Elements/New-LabelElement.cs deleted file mode 100644 index 268637c..0000000 --- a/src/Elements/New-LabelElement.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new label element. -/// -[Cmdlet(VerbsCommon.New, "HtmlLabelElement"), Alias("label"), OutputType(typeof(string))] -public class NewLabelElementCommand(): NewElementCommand("label", isVoid: false) { - - /// - /// The identifier of the labelable form control in the same document. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? For { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(For)) attributes["for"] = For; - } -} diff --git a/src/Elements/New-LabelElement.psm1 b/src/Elements/New-LabelElement.psm1 new file mode 100644 index 0000000..c4bbb97 --- /dev/null +++ b/src/Elements/New-LabelElement.psm1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Creates a new `label` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlLabelElement"), Alias("label"), OutputType(typeof(string))] +function New-HtmlLabelElementCommand(): NewElementCommand("label", isVoid: false) { + + <# + .SYNOPSIS + The identifier of the labelable form control in the same document. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $For + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(For)) attributes["for"] = For; + } +} diff --git a/src/Elements/New-LiElement.cs b/src/Elements/New-LiElement.cs deleted file mode 100644 index b9430a0..0000000 --- a/src/Elements/New-LiElement.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new li element. -/// -[Cmdlet(VerbsCommon.New, "HtmlLiElement"), Alias("li"), OutputType(typeof(string))] -public class NewLiElementCommand(): NewElementCommand("li", isVoid: false) { - - /// - /// The ordinal value of the list item as defined by the ol element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public int? Value { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-LiElement.psm1 b/src/Elements/New-LiElement.psm1 new file mode 100644 index 0000000..0877765 --- /dev/null +++ b/src/Elements/New-LiElement.psm1 @@ -0,0 +1,26 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `li` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlLiElement"), Alias("li"), OutputType(typeof(string))] +function New-HtmlLiElementCommand(): NewElementCommand("li", isVoid: false) { + + <# + .SYNOPSIS + The ordinal value of the list item as defined by the `ol` element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [int] $Value + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-LinkElement.cs b/src/Elements/New-LinkElement.cs deleted file mode 100644 index 32a00cb..0000000 --- a/src/Elements/New-LinkElement.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new link element. -/// -[Cmdlet(VerbsCommon.New, "HtmlLinkElement"), Alias("link"), OutputType(typeof(string))] -public class NewLinkElementCommand(): NewElementCommand("link", isVoid: true) { - - /// - /// Specifies the type of content being loaded by the link. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? As { get; set; } - - /// - /// Value indicating whether CORS must be used when fetching the resource. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("anonymous", "use-credentials")] - public string? CrossOrigin { get; set; } - - /// - /// The URL of the linked resource. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Href { get; set; } - - /// - /// A base64-encoded cryptographic hash of the resource (file) to fetch. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Integrity { get; set; } - - /// - /// The media that the linked resource applies to. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Media { get; set; } - - /// - /// The relationship of the linked resource to the current document. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required string[] Rel { get; set; } - - /// - /// The sizes of the icons for visual media contained in the resource. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Sizes { get; set; } = []; - - /// - /// The media type of the content linked to. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Type { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["rel"] = string.Join(' ', Rel).Trim(); - attributes["href"] = Href.ToString(); - if (!string.IsNullOrWhiteSpace(As)) attributes["as"] = As; - if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (!string.IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; - if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; - if (Sizes.Length > 0) attributes["sizes"] = string.Join(' ', Sizes).Trim(); - if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; - } -} diff --git a/src/Elements/New-LinkElement.psm1 b/src/Elements/New-LinkElement.psm1 new file mode 100644 index 0000000..fc50660 --- /dev/null +++ b/src/Elements/New-LinkElement.psm1 @@ -0,0 +1,81 @@ +<# +.SYNOPSIS + Creates a new `link` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlLinkElement"), Alias("link"), OutputType(typeof(string))] +function New-HtmlLinkElementCommand(): NewElementCommand("link", isVoid: true) { + + <# + .SYNOPSIS + Specifies the type of content being loaded by the `link`. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $As + + <# + .SYNOPSIS + Value indicating whether CORS must be used when fetching the resource. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("anonymous", "use-credentials")] + [string] $CrossOrigin + + <# + .SYNOPSIS + The URL of the linked resource. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [uri] $Href + + <# + .SYNOPSIS + A base64-encoded cryptographic hash of the resource (file) to fetch. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Integrity + + <# + .SYNOPSIS + The media that the linked resource applies to. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Media + + <# + .SYNOPSIS + The relationship of the linked resource to the current document. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required [string[]] $Rel + + <# + .SYNOPSIS + The sizes of the icons for visual media contained in the resource. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Sizes = []; + + <# + .SYNOPSIS + The media type of the content linked to. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Type + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["rel"] = string.Join(' ', Rel).Trim(); + attributes["href"] = Href.ToString(); + if (!string.IsNullOrWhiteSpace(As)) attributes["as"] = As; + if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; + if (!string.IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; + if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; + if (Sizes.Length > 0) attributes["sizes"] = string.Join(' ', Sizes).Trim(); + if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + } +} diff --git a/src/Elements/New-MapElement.cs b/src/Elements/New-MapElement.cs deleted file mode 100644 index 5d5ad3c..0000000 --- a/src/Elements/New-MapElement.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new map element. -/// -[Cmdlet(VerbsCommon.New, "HtmlMapElement"), Alias("map"), OutputType(typeof(string))] -public class NewMapElementCommand(): NewElementCommand("map", isVoid: false) { - - /// - /// The map name so that it can be referenced. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - } -} diff --git a/src/Elements/New-MapElement.psm1 b/src/Elements/New-MapElement.psm1 new file mode 100644 index 0000000..d9c608c --- /dev/null +++ b/src/Elements/New-MapElement.psm1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Creates a new `map` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlMapElement"), Alias("map"), OutputType(typeof(string))] +function New-HtmlMapElementCommand(): NewElementCommand("map", isVoid: false) { + + <# + .SYNOPSIS + The map name so that it can be referenced. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + } +} diff --git a/src/Elements/New-MetaElement.cs b/src/Elements/New-MetaElement.cs deleted file mode 100644 index 7ac5eb8..0000000 --- a/src/Elements/New-MetaElement.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new meta element. -/// -[Cmdlet(VerbsCommon.New, "HtmlMetaElement", DefaultParameterSetName = nameof(Name)), Alias("meta"), OutputType(typeof(string))] -public class NewMetaElementCommand(): NewElementCommand("meta", isVoid: true) { - - /// - /// A charset declaration, giving the character encoding in which the document is encoded. - /// - [Parameter(Mandatory = true, ParameterSetName = nameof(Charset), ValueFromPipelineByPropertyName = true)] - public required string Charset { get; set; } - - /// - /// Contains the value for the http-equiv or name attribute, depending on which is used. - /// - [Parameter(Mandatory = true, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName = true)] - [Parameter(Mandatory = true, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName = true)] - public override object? Content { get => base.Content; set => base.Content = value; } - - /// - /// A pragma directive to simulate directives that could otherwise be given by an HTTP header. - /// - [Parameter(Mandatory = true, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName = true)] - public required string HttpEquiv { get; set; } - - /// - /// Document-level metadata that applies to the whole page. - /// - [Parameter(Mandatory = true, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName = true)] - public required string Name { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - - switch (ParameterSetName) { - case nameof(Charset): - attributes["charset"] = Charset; - break; - case nameof(HttpEquiv): - attributes["http-equiv"] = HttpEquiv; - attributes["content"] = Content; - break; - case nameof(Name): - attributes["name"] = Name; - attributes["content"] = Content; - break; - } - } -} diff --git a/src/Elements/New-MetaElement.psm1 b/src/Elements/New-MetaElement.psm1 new file mode 100644 index 0000000..933c272 --- /dev/null +++ b/src/Elements/New-MetaElement.psm1 @@ -0,0 +1,59 @@ +<# +.SYNOPSIS + Creates a new `meta` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlMetaElement", DefaultParameterSetName = nameof(Name)), Alias("meta"), OutputType(typeof(string))] +function New-HtmlMetaElementCommand(): NewElementCommand("meta", isVoid: true) { + + <# + .SYNOPSIS + A charset declaration, giving the character encoding in which the document is encoded. + #> + [Parameter(Mandatory = true, ParameterSetName = nameof(Charset), ValueFromPipelineByPropertyName)] + required string Charset + + <# + .SYNOPSIS + Contains the value for the `http-equiv` or `name attribute`, depending on which is used. + #> + [Parameter(Mandatory = true, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = true, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName)] + override [object] $Content { get => base.Content; set => base.Content = value; } + + <# + .SYNOPSIS + A pragma directive to simulate directives that could otherwise be given by an HTTP header. + #> + [Parameter(Mandatory = true, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName)] + required string HttpEquiv + + <# + .SYNOPSIS + Document-level metadata that applies to the whole page. + #> + [Parameter(Mandatory = true, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName)] + required string Name + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + + switch (ParameterSetName) { + case nameof(Charset): + attributes["charset"] = Charset; + break; + case nameof(HttpEquiv): + attributes["http-equiv"] = HttpEquiv; + attributes["content"] = Content; + break; + case nameof(Name): + attributes["name"] = Name; + attributes["content"] = Content; + break; + } + } +} diff --git a/src/Elements/New-MeterElement.cs b/src/Elements/New-MeterElement.cs deleted file mode 100644 index 3b9b448..0000000 --- a/src/Elements/New-MeterElement.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new meter element. -/// -[Cmdlet(VerbsCommon.New, "HtmlMeterElement"), Alias("meter"), OutputType(typeof(string))] -public class NewMeterElementCommand(): NewElementCommand("meter", isVoid: false) { - - /// - /// The lower numeric bound of the high end of the measured range. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public double? High { get; set; } - - /// - /// The upper numeric bound of the low end of the measured range. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public double? Low { get; set; } - - /// - /// The upper numeric bound of the measured range. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public double? Max { get; set; } - - /// - /// The lower numeric bound of the measured range. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public double? Min { get; set; } - - /// - /// The optimal numeric value. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public double? Optimum { get; set; } - - /// - /// The current numeric value. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public double? Value { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (High is not null) attributes["high"] = High.Value.ToString(CultureInfo.InvariantCulture); - if (Low is not null) attributes["low"] = Low.Value.ToString(CultureInfo.InvariantCulture); - if (Max is not null) attributes["max"] = Max.Value.ToString(CultureInfo.InvariantCulture); - if (Min is not null) attributes["min"] = Min.Value.ToString(CultureInfo.InvariantCulture); - if (Optimum is not null) attributes["optimum"] = Optimum.Value.ToString(CultureInfo.InvariantCulture); - if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-MeterElement.psm1 b/src/Elements/New-MeterElement.psm1 new file mode 100644 index 0000000..b644020 --- /dev/null +++ b/src/Elements/New-MeterElement.psm1 @@ -0,0 +1,66 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `meter` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlMeterElement"), Alias("meter"), OutputType(typeof(string))] +function New-HtmlMeterElementCommand(): NewElementCommand("meter", isVoid: false) { + + <# + .SYNOPSIS + The lower numeric bound of the high end of the measured range. + #> + [Parameter(ValueFromPipelineByPropertyName)] + double? High + + <# + .SYNOPSIS + The upper numeric bound of the low end of the measured range. + #> + [Parameter(ValueFromPipelineByPropertyName)] + double? Low + + <# + .SYNOPSIS + The upper numeric bound of the measured range. + #> + [Parameter(ValueFromPipelineByPropertyName)] + double? Max + + <# + .SYNOPSIS + The lower numeric bound of the measured range. + #> + [Parameter(ValueFromPipelineByPropertyName)] + double? Min + + <# + .SYNOPSIS + The optimal numeric value. + #> + [Parameter(ValueFromPipelineByPropertyName)] + double? Optimum + + <# + .SYNOPSIS + The current numeric value. + #> + [Parameter(ValueFromPipelineByPropertyName)] + double? Value + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (High is not null) attributes["high"] = High.Value.ToString(CultureInfo.InvariantCulture); + if (Low is not null) attributes["low"] = Low.Value.ToString(CultureInfo.InvariantCulture); + if (Max is not null) attributes["max"] = Max.Value.ToString(CultureInfo.InvariantCulture); + if (Min is not null) attributes["min"] = Min.Value.ToString(CultureInfo.InvariantCulture); + if (Optimum is not null) attributes["optimum"] = Optimum.Value.ToString(CultureInfo.InvariantCulture); + if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-ObjectElement.cs b/src/Elements/New-ObjectElement.cs deleted file mode 100644 index 19f06a4..0000000 --- a/src/Elements/New-ObjectElement.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new object element. -/// -[Cmdlet(VerbsCommon.New, "HtmlObjectElement"), Alias("object"), OutputType(typeof(string))] -public class NewObjectElementCommand(): NewElementCommand("object", isVoid: false) { - - /// - /// The URL of the resource being embedded. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Data { get; set; } - - /// - /// The identifier of a form element to associate with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Form { get; set; } - - /// - /// The height of the display resource, in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Height { get; set; } = -1; - - /// - /// The name of valid browsing context (HTML 5), or the name of the control (HTML 4). - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// The media type to use, optionally including a codecs parameter. - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required string Type { get; set; } - - /// - /// The width of the display resource, in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Width { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["data"] = Data.ToString(); - attributes["type"] = Type; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-ObjectElement.psm1 b/src/Elements/New-ObjectElement.psm1 new file mode 100644 index 0000000..6f234dd --- /dev/null +++ b/src/Elements/New-ObjectElement.psm1 @@ -0,0 +1,66 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `object` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlObjectElement"), Alias("object"), OutputType(typeof(string))] +function New-HtmlObjectElementCommand(): NewElementCommand("object", isVoid: false) { + + <# + .SYNOPSIS + The URL of the resource being embedded. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required Uri Data + + <# + .SYNOPSIS + The identifier of a `form` element to associate with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Form + + <# + .SYNOPSIS + The height of the display resource, in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Height = -1; + + <# + .SYNOPSIS + The name of valid browsing context (HTML 5), or the name of the control (HTML 4). + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + The media type to use, optionally including a `codecs` parameter. + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required string Type + + <# + .SYNOPSIS + The width of the display resource, in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Width = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["data"] = Data.ToString(); + attributes["type"] = Type; + if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-OlElement.cs b/src/Elements/New-OlElement.cs deleted file mode 100644 index cea43ab..0000000 --- a/src/Elements/New-OlElement.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new ol element. -/// -[Cmdlet(VerbsCommon.New, "HtmlOlElement"), Alias("ol"), OutputType(typeof(string))] -public class NewOlElementCommand(): NewElementCommand("ol", isVoid: false) { - - /// - /// Value indicating whether the list's items are in reverse order. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Reversed { get; set; } - - /// - /// An integer to start counting from for the list items. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public int? Start { get; set; } - - /// - /// Value indicating the current ordinal value of the list item as defined by the ol element. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("1", "A", "a", "I", "i")] - public string? Type { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Reversed) attributes["reversed"] = true; - if (Start is not null) attributes["start"] = Start.Value.ToString(CultureInfo.InvariantCulture); - if (Type is not null) attributes["type"] = Type; - } -} diff --git a/src/Elements/New-OlElement.psm1 b/src/Elements/New-OlElement.psm1 new file mode 100644 index 0000000..7f3a6dd --- /dev/null +++ b/src/Elements/New-OlElement.psm1 @@ -0,0 +1,43 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `ol` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlOlElement"), Alias("ol"), OutputType(typeof(string))] +function New-HtmlOlElementCommand(): NewElementCommand("ol", isVoid: false) { + + <# + .SYNOPSIS + Value indicating whether the list's items are in reverse order. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Reversed + + <# + .SYNOPSIS + An integer to start counting from for the list items. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [int] $Start + + <# + .SYNOPSIS + Value indicating the current ordinal value of the list item as defined by the `ol` element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("1", "A", "a", "I", "i")] + [string] $Type + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Reversed) attributes["reversed"] = true; + if (Start is not null) attributes["start"] = Start.Value.ToString(CultureInfo.InvariantCulture); + if (Type is not null) attributes["type"] = Type; + } +} diff --git a/src/Elements/New-OptgroupElement.cs b/src/Elements/New-OptgroupElement.cs deleted file mode 100644 index dafb281..0000000 --- a/src/Elements/New-OptgroupElement.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new optgroup element. -/// -[Cmdlet(VerbsCommon.New, "HtmlOptgroupElement"), Alias("optgroup"), OutputType(typeof(string))] -public class NewOptgroupElementCommand(): NewElementCommand("optgroup", isVoid: false) { - - /// - /// Value indicating whether none of the items in the option group is selectable. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Disabled { get; set; } - - /// - /// The name of the group of options. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public required string Label { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["label"] = Label; - if (Disabled) attributes["disabled"] = true; - } -} diff --git a/src/Elements/New-OptgroupElement.psm1 b/src/Elements/New-OptgroupElement.psm1 new file mode 100644 index 0000000..6ae806b --- /dev/null +++ b/src/Elements/New-OptgroupElement.psm1 @@ -0,0 +1,32 @@ +<# +.SYNOPSIS + Creates a new `optgroup` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlOptgroupElement"), Alias("optgroup"), OutputType(typeof(string))] +function New-HtmlOptgroupElementCommand(): NewElementCommand("optgroup", isVoid: false) { + + <# + .SYNOPSIS + Value indicating whether none of the items in the option group is selectable. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Disabled + + <# + .SYNOPSIS + The name of the group of options. + #> + [Parameter(ValueFromPipelineByPropertyName)] + required string Label + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["label"] = Label; + if (Disabled) attributes["disabled"] = true; + } +} diff --git a/src/Elements/New-OptionElement.cs b/src/Elements/New-OptionElement.cs deleted file mode 100644 index a491f63..0000000 --- a/src/Elements/New-OptionElement.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new option element. -/// -[Cmdlet(VerbsCommon.New, "HtmlOptionElement"), Alias("option"), OutputType(typeof(string))] -public class NewOptionElementCommand(): NewElementCommand("option", isVoid: false) { - - /// - /// Value indicating whether the option is not checkable. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Disabled { get; set; } - - /// - /// The label indicating the meaning of the option. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Label { get; set; } - - /// - /// Value indicating whether the option is initially selected. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Selected { get; set; } - - /// - /// The value to be submitted with the form. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Value { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Label)) attributes["label"] = Label; - if (Selected) attributes["selected"] = true; - if (Value is not null) attributes["value"] = Value; - } -} diff --git a/src/Elements/New-OptionElement.psm1 b/src/Elements/New-OptionElement.psm1 new file mode 100644 index 0000000..e2feba2 --- /dev/null +++ b/src/Elements/New-OptionElement.psm1 @@ -0,0 +1,48 @@ +<# +.SYNOPSIS + Creates a new `option` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlOptionElement"), Alias("option"), OutputType(typeof(string))] +function New-HtmlOptionElementCommand(): NewElementCommand("option", isVoid: false) { + + <# + .SYNOPSIS + Value indicating whether the option is not checkable. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Disabled + + <# + .SYNOPSIS + The label indicating the meaning of the option. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Label + + <# + .SYNOPSIS + Value indicating whether the option is initially selected. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Selected + + <# + .SYNOPSIS + The value to be submitted with the form. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Value + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Disabled) attributes["disabled"] = true; + if (!string.IsNullOrWhiteSpace(Label)) attributes["label"] = Label; + if (Selected) attributes["selected"] = true; + if (Value is not null) attributes["value"] = Value; + } +} diff --git a/src/Elements/New-OutputElement.cs b/src/Elements/New-OutputElement.cs deleted file mode 100644 index b8eab1f..0000000 --- a/src/Elements/New-OutputElement.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new output element. -/// -[Cmdlet(VerbsCommon.New, "HtmlOutputElement"), Alias("output"), OutputType(typeof(string))] -public class NewOutputElementCommand(): NewElementCommand("output", isVoid: false) { - - /// - /// A list of other elements' identifiers, indicating that those elements contributed input values to the calculation. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] For { get; set; } = []; - - /// - /// The identifier of a form element to associate with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Form { get; set; } - - /// - /// The element's name. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (For.Length > 0) attributes["for"] = string.Join(' ', For).Trim(); - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - } -} diff --git a/src/Elements/New-OutputElement.psm1 b/src/Elements/New-OutputElement.psm1 new file mode 100644 index 0000000..b1ffc2c --- /dev/null +++ b/src/Elements/New-OutputElement.psm1 @@ -0,0 +1,40 @@ +<# +.SYNOPSIS + Creates a new `output` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlOutputElement"), Alias("output"), OutputType(typeof(string))] +function New-HtmlOutputElementCommand(): NewElementCommand("output", isVoid: false) { + + <# + .SYNOPSIS + A list of other elements' identifiers, indicating that those elements contributed input values to the calculation. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $For = []; + + <# + .SYNOPSIS + The identifier of a `form` element to associate with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Form + + <# + .SYNOPSIS + The element's name. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (For.Length > 0) attributes["for"] = string.Join(' ', For).Trim(); + if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + } +} diff --git a/src/Elements/New-ProgressElement.cs b/src/Elements/New-ProgressElement.cs deleted file mode 100644 index c22d8e5..0000000 --- a/src/Elements/New-ProgressElement.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new progress element. -/// -[Cmdlet(VerbsCommon.New, "HtmlProgressElement"), Alias("progress"), OutputType(typeof(string))] -public class NewProgressElementCommand(): NewElementCommand("progress", isVoid: false) { - - /// - /// Describes how much work the task requires. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public double? Max { get; set; } - - /// - /// Specifies how much of the task that has been completed. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public double? Value { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Max is not null) attributes["max"] = Max.Value.ToString(CultureInfo.InvariantCulture); - if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-ProgressElement.psm1 b/src/Elements/New-ProgressElement.psm1 new file mode 100644 index 0000000..62542d6 --- /dev/null +++ b/src/Elements/New-ProgressElement.psm1 @@ -0,0 +1,34 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `progress` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlProgressElement"), Alias("progress"), OutputType(typeof(string))] +function New-HtmlProgressElementCommand(): NewElementCommand("progress", isVoid: false) { + + <# + .SYNOPSIS + Describes how much work the task requires. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + double? Max + + <# + .SYNOPSIS + Specifies how much of the task that has been completed. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + double? Value + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Max is not null) attributes["max"] = Max.Value.ToString(CultureInfo.InvariantCulture); + if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-QElement.cs b/src/Elements/New-QElement.cs deleted file mode 100644 index 15d5f4c..0000000 --- a/src/Elements/New-QElement.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new q element. -/// -[Cmdlet(VerbsCommon.New, "HtmlQElement"), Alias("q"), OutputType(typeof(string))] -public class NewQElementCommand(): NewElementCommand("q", isVoid: false) { - - /// - /// A URL that designates a source document or message for the information quoted. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Cite { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Cite is not null) attributes["cite"] = Cite.ToString(); - } -} diff --git a/src/Elements/New-QElement.psm1 b/src/Elements/New-QElement.psm1 new file mode 100644 index 0000000..3020373 --- /dev/null +++ b/src/Elements/New-QElement.psm1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Creates a new `q` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlQElement"), Alias("q"), OutputType(typeof(string))] +function New-HtmlQElementCommand(): NewElementCommand("q", isVoid: false) { + + <# + .SYNOPSIS + A URL that designates a source document or message for the information quoted. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Cite + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Cite is not null) attributes["cite"] = Cite.ToString(); + } +} diff --git a/src/Elements/New-ScriptElement.cs b/src/Elements/New-ScriptElement.cs deleted file mode 100644 index fb478a5..0000000 --- a/src/Elements/New-ScriptElement.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new script element. -/// -[Cmdlet(VerbsCommon.New, "HtmlScriptElement"), Alias("script"), OutputType(typeof(string))] -public class NewScriptElementCommand(): NewElementCommand("script", isVoid: false) { - - /// - /// Value indicating whether the script will be fetched in parallel to parsing and evaluated as soon as it is available. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Async { get; set; } - - /// - /// Value indicating whether CORS must be used when fetching the resource. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("anonymous", "use-credentials")] - public string? CrossOrigin { get; set; } - - /// - /// Value indicating whether the script is meant to be executed after the document has been parsed, but before firing DOMContentLoaded event. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Defer { get; set; } - - /// - /// A base64-encoded cryptographic hash of the resource (file) to fetch. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Integrity { get; set; } - - /// - /// The URI of an external script. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Src { get; set; } - - /// - /// The type of script represented. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Type { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (Src is not null) attributes["src"] = Src.ToString(); - if (Async) attributes["async"] = true; - if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (Defer) attributes["defer"] = true; - if (!string.IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; - if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; - } -} diff --git a/src/Elements/New-ScriptElement.psm1 b/src/Elements/New-ScriptElement.psm1 new file mode 100644 index 0000000..aa74ee4 --- /dev/null +++ b/src/Elements/New-ScriptElement.psm1 @@ -0,0 +1,65 @@ +<# +.SYNOPSIS + Creates a new `script` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlScriptElement"), Alias("script"), OutputType(typeof(string))] +function New-HtmlScriptElementCommand(): NewElementCommand("script", isVoid: false) { + + <# + .SYNOPSIS + Value indicating whether the script will be fetched in parallel to parsing and evaluated as soon as it is available. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Async + + <# + .SYNOPSIS + Value indicating whether CORS must be used when fetching the resource. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("anonymous", "use-credentials")] + [string] $CrossOrigin + + <# + .SYNOPSIS + Value indicating whether the script is meant to be executed after the document has been parsed, but before firing `DOMContentLoaded` event. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Defer + + <# + .SYNOPSIS + A base64-encoded cryptographic hash of the resource (file) to fetch. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Integrity + + <# + .SYNOPSIS + The URI of an external script. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Src + + <# + .SYNOPSIS + The type of script represented. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Type + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (Src is not null) attributes["src"] = Src.ToString(); + if (Async) attributes["async"] = true; + if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; + if (Defer) attributes["defer"] = true; + if (!string.IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; + if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + } +} diff --git a/src/Elements/New-SelectElement.cs b/src/Elements/New-SelectElement.cs deleted file mode 100644 index 4d38e55..0000000 --- a/src/Elements/New-SelectElement.cs +++ /dev/null @@ -1,67 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new select element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSelectElement"), Alias("selectTag"), OutputType(typeof(string))] -public class NewSelectElementCommand(): NewElementCommand("select", isVoid: false) { - - /// - /// A hint for a user agent's autocomplete feature. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] AutoComplete { get; set; } = []; - - /// - /// Value indicating whether to prevent the user from interacting with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Disabled { get; set; } - - /// - /// The identifier of a form element to associate with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Form { get; set; } - - /// - /// Value indicating whether multiple options can be selected in the list. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Multiple { get; set; } - - /// - /// The name of the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// Value indicating whether an option with a non-empty string value must be selected. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Required { get; set; } - - /// - /// The number of rows in the list that should be visible at one time. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Size { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); - if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (Multiple) attributes["multiple"] = true; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Required) attributes["required"] = true; - if (Size >= 0) attributes["size"] = Size.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-SelectElement.psm1 b/src/Elements/New-SelectElement.psm1 new file mode 100644 index 0000000..0e2f7b3 --- /dev/null +++ b/src/Elements/New-SelectElement.psm1 @@ -0,0 +1,74 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `select` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlSelectElement"), Alias("selectTag"), OutputType(typeof(string))] +function New-HtmlSelectElementCommand(): NewElementCommand("select", isVoid: false) { + + <# + .SYNOPSIS + A hint for a user agent's autocomplete feature. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $AutoComplete = []; + + <# + .SYNOPSIS + Value indicating whether to prevent the user from interacting with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Disabled + + <# + .SYNOPSIS + The identifier of a `form` element to associate with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Form + + <# + .SYNOPSIS + Value indicating whether multiple options can be selected in the list. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Multiple + + <# + .SYNOPSIS + The name of the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + Value indicating whether an option with a non-empty string value must be selected. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Required + + <# + .SYNOPSIS + The number of rows in the list that should be visible at one time. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Size = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); + if (Disabled) attributes["disabled"] = true; + if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (Multiple) attributes["multiple"] = true; + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (Required) attributes["required"] = true; + if (Size >= 0) attributes["size"] = Size.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-SlotElement.cs b/src/Elements/New-SlotElement.cs deleted file mode 100644 index 1e44c34..0000000 --- a/src/Elements/New-SlotElement.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new slot element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSlotElement"), Alias("slot"), OutputType(typeof(string))] -public class NewSlotElementCommand(): NewElementCommand("slot", isVoid: false) { - - /// - /// The slot's name. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - } -} diff --git a/src/Elements/New-SlotElement.psm1 b/src/Elements/New-SlotElement.psm1 new file mode 100644 index 0000000..ad9134f --- /dev/null +++ b/src/Elements/New-SlotElement.psm1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Creates a new `slot` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlSlotElement"), Alias("slot"), OutputType(typeof(string))] +function New-HtmlSlotElementCommand(): NewElementCommand("slot", isVoid: false) { + + <# + .SYNOPSIS + The slot's name. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + } +} diff --git a/src/Elements/New-SourceElement.cs b/src/Elements/New-SourceElement.cs deleted file mode 100644 index 879e941..0000000 --- a/src/Elements/New-SourceElement.cs +++ /dev/null @@ -1,75 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new source element. -/// -[Cmdlet(VerbsCommon.New, "HtmlSourceElement", DefaultParameterSetName = nameof(Src)), Alias("source"), OutputType(typeof(string))] -public class NewSourceElementCommand(): NewElementCommand("source", isVoid: true) { - - /// - /// The intrinsic height of the image, in CSS pixels. - /// - [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Height { get; set; } = -1; - - /// - /// The media query for the resource's intended media. - /// - [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName = true)] - public string? Media { get; set; } - - /// - /// A list of source sizes that describe the final rendered width of the image. - /// - [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName = true)] - public string[] Sizes { get; set; } = []; - - /// - /// The URL of the media resource - /// - [Parameter(Mandatory = true, ParameterSetName = nameof(Src), ValueFromPipelineByPropertyName = true)] - public required Uri Src { get; set; } - - /// - /// A list of one or more image URLs and their descriptors. - /// - [Parameter(Mandatory = true, ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName = true)] - public string[] SrcSet { get; set; } = []; - - /// - /// The media type to use, optionally including a codecs parameter. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Type { get; set; } - - /// - /// The intrinsic width of the image, in CSS pixels. - /// - [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Width { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; - - switch (ParameterSetName) { - case nameof(Src): - attributes["src"] = Src.ToString(); - break; - - case nameof(SrcSet): - attributes["srcset"] = string.Join(", ", SrcSet); - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; - if (Sizes.Length > 0) attributes["sizes"] = string.Join(", ", Sizes); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); - break; - } - } -} diff --git a/src/Elements/New-SourceElement.psm1 b/src/Elements/New-SourceElement.psm1 new file mode 100644 index 0000000..756d33f --- /dev/null +++ b/src/Elements/New-SourceElement.psm1 @@ -0,0 +1,82 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `source` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlSourceElement", DefaultParameterSetName = nameof(Src)), Alias("source"), OutputType(typeof(string))] +function New-HtmlSourceElementCommand(): NewElementCommand("source", isVoid: true) { + + <# + .SYNOPSIS + The intrinsic height of the image, in CSS pixels. + #> + [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Height = -1; + + <# + .SYNOPSIS + The media query for the resource's intended media. + #> + [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] + [string] $Media + + <# + .SYNOPSIS + A list of source sizes that describe the final rendered width of the image. + #> + [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] + [string[]] $Sizes = []; + + <# + .SYNOPSIS + The URL of the media resource + #> + [Parameter(Mandatory = true, ParameterSetName = nameof(Src), ValueFromPipelineByPropertyName)] + required Uri Src + + <# + .SYNOPSIS + A list of one or more image URLs and their descriptors. + #> + [Parameter(Mandatory = true, ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] + [string[]] $SrcSet = []; + + <# + .SYNOPSIS + The media type to use, optionally including a `codecs` parameter. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Type + + <# + .SYNOPSIS + The intrinsic width of the image, in CSS pixels. + #> + [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Width = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + + switch (ParameterSetName) { + case nameof(Src): + attributes["src"] = Src.ToString(); + break; + + case nameof(SrcSet): + attributes["srcset"] = string.Join(", ", SrcSet); + if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; + if (Sizes.Length > 0) attributes["sizes"] = string.Join(", ", Sizes); + if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + break; + } + } +} diff --git a/src/Elements/New-StyleElement.cs b/src/Elements/New-StyleElement.cs deleted file mode 100644 index f3f3bef..0000000 --- a/src/Elements/New-StyleElement.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new style element. -/// -[Cmdlet(VerbsCommon.New, "HtmlStyleElement"), Alias("style"), OutputType(typeof(string))] -public class NewStyleElementCommand(): NewElementCommand("style", isVoid: false) { - - /// - /// Defines which media the style should be applied to. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Media { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; - } -} diff --git a/src/Elements/New-StyleElement.psm1 b/src/Elements/New-StyleElement.psm1 new file mode 100644 index 0000000..da1a8e2 --- /dev/null +++ b/src/Elements/New-StyleElement.psm1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Creates a new `style` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlStyleElement"), Alias("style"), OutputType(typeof(string))] +function New-HtmlStyleElementCommand(): NewElementCommand("style", isVoid: false) { + + <# + .SYNOPSIS + Defines which media the style should be applied to. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Media + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; + } +} diff --git a/src/Elements/New-TdElement.cs b/src/Elements/New-TdElement.cs deleted file mode 100644 index bb71239..0000000 --- a/src/Elements/New-TdElement.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new th element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTdElement"), Alias("td"), OutputType(typeof(string))] -public class NewTdElementCommand(): NewElementCommand("td", isVoid: false) { - - /// - /// An integer indicating how many columns the header cell spans or extends. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int ColSpan { get; set; } = -1; - - /// - /// A list of strings corresponding to the id attributes of the th elements that provide the headers for this header cell. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Headers { get; set; } = []; - - /// - /// An integer indicating how many rows the header cell spans or extends. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int RowSpan { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (ColSpan >= 0) attributes["colspan"] = ColSpan.ToString(CultureInfo.InvariantCulture); - if (Headers.Length > 0) attributes["headers"] = string.Join(' ', Headers).Trim(); - if (RowSpan >= 0) attributes["rowspan"] = RowSpan.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-TdElement.psm1 b/src/Elements/New-TdElement.psm1 new file mode 100644 index 0000000..e3e4e6f --- /dev/null +++ b/src/Elements/New-TdElement.psm1 @@ -0,0 +1,42 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `th` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlTdElement"), Alias("td"), OutputType(typeof(string))] +function New-HtmlTdElementCommand(): NewElementCommand("td", isVoid: false) { + + <# + .SYNOPSIS + An integer indicating how many columns the header cell spans or extends. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int ColSpan = -1; + + <# + .SYNOPSIS + A list of strings corresponding to the `id` attributes of the `th` elements that provide the headers for this header cell. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Headers = []; + + <# + .SYNOPSIS + An integer indicating how many rows the header cell spans or extends. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int RowSpan = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (ColSpan >= 0) attributes["colspan"] = ColSpan.ToString(CultureInfo.InvariantCulture); + if (Headers.Length > 0) attributes["headers"] = string.Join(' ', Headers).Trim(); + if (RowSpan >= 0) attributes["rowspan"] = RowSpan.ToString(CultureInfo.InvariantCulture); + } +} diff --git a/src/Elements/New-TemplateElement.cs b/src/Elements/New-TemplateElement.cs deleted file mode 100644 index 2cca45c..0000000 --- a/src/Elements/New-TemplateElement.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new template element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTemplateElement"), Alias("template"), OutputType(typeof(string))] -public class NewTemplateElementCommand(): NewElementCommand("template", isVoid: false) { - - /// - /// Value indicating whether the shadow root is clonable. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter ShadowRootClonable { get; set; } - - /// - /// Value indicating whether the shadow root delegates focus. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter ShadowRootDelegatesFocus { get; set; } - - /// - /// Value indicating whether to create a shadow root for the parent element. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("closed", "open")] - public string? ShadowRootMode { get; set; } - - /// - /// Value indicating whether the shadow root is serializable. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter ShadowRootSerializable { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (ShadowRootMode is not null) attributes["shadowrootmode"] = ShadowRootMode; - if (ShadowRootClonable) attributes["shadowrootclonable"] = true; - if (ShadowRootDelegatesFocus) attributes["shadowrootdelegatesfocus"] = true; - if (ShadowRootSerializable) attributes["shadowrootserializable"] = true; - } -} diff --git a/src/Elements/New-TemplateElement.psm1 b/src/Elements/New-TemplateElement.psm1 new file mode 100644 index 0000000..0e69db7 --- /dev/null +++ b/src/Elements/New-TemplateElement.psm1 @@ -0,0 +1,49 @@ +<# +.SYNOPSIS + Creates a new `template` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlTemplateElement"), Alias("template"), OutputType(typeof(string))] +function New-HtmlTemplateElementCommand(): NewElementCommand("template", isVoid: false) { + + <# + .SYNOPSIS + Value indicating whether the shadow root is clonable. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $ShadowRootClonable + + <# + .SYNOPSIS + Value indicating whether the shadow root delegates focus. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $ShadowRootDelegatesFocus + + <# + .SYNOPSIS + Value indicating whether to create a shadow root for the parent element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("closed", "open")] + [string] $ShadowRootMode + + <# + .SYNOPSIS + Value indicating whether the shadow root is serializable. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $ShadowRootSerializable + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (ShadowRootMode is not null) attributes["shadowrootmode"] = ShadowRootMode; + if (ShadowRootClonable) attributes["shadowrootclonable"] = true; + if (ShadowRootDelegatesFocus) attributes["shadowrootdelegatesfocus"] = true; + if (ShadowRootSerializable) attributes["shadowrootserializable"] = true; + } +} diff --git a/src/Elements/New-TextareaElement.cs b/src/Elements/New-TextareaElement.cs deleted file mode 100644 index 2145bd8..0000000 --- a/src/Elements/New-TextareaElement.cs +++ /dev/null @@ -1,116 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new textarea element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTextareaElement"), Alias("textarea"), OutputType(typeof(string))] -public class NewTextareaElementCommand(): NewElementCommand("textarea", isVoid: false) { - - /// - /// A hint for a user agent's autocomplete feature. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] AutoComplete { get; set; } = []; - - /// - /// Value indicating whether automatic spelling correction and processing of text is enabled. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("off", "on")] - public string? AutoCorrect { get; set; } - - /// - /// The visible width of the text control, in average character widths. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.Positive)] - public int Cols { get; set; } - - /// - /// The field name to use for sending the element's directionality in form submission. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? DirName { get; set; } - - /// - /// Value indicating whether to prevent the user from interacting with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Disabled { get; set; } - - /// - /// The identifier of a form element to associate with the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Form { get; set; } - - /// - /// The maximum string length that the user can enter. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int MaxLength { get; set; } = -1; - - /// - /// The minimum string length required that the user should enter. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int MinLength { get; set; } = -1; - - /// - /// The name of the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Name { get; set; } - - /// - /// A hint to the user of what can be entered in the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Placeholder { get; set; } - - /// - /// Value indicating whether the user cannot modify the value of the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter ReadOnly { get; set; } - - /// - /// Value indicating whether the user must fill in a value before submitting a form. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Required { get; set; } - - /// - /// The number of visible text lines for the control. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.Positive)] - public int Rows { get; set; } - - /// - /// Value indicating whether the control should wrap the value for form submission. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("hard", "soft")] - public string? Wrap { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); - if (AutoCorrect is not null) attributes["autocorrect"] = AutoCorrect; - if (Cols > 0) attributes["cols"] = Cols.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; - if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (MaxLength >= 0) attributes["maxlength"] = MaxLength.ToString(CultureInfo.InvariantCulture); - if (MinLength >= 0) attributes["minlength"] = MinLength.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (!string.IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; - if (ReadOnly) attributes["readonly"] = true; - if (Required) attributes["required"] = true; - if (Rows > 0) attributes["rows"] = Rows.ToString(CultureInfo.InvariantCulture); - if (Wrap is not null) attributes["wrap"] = Wrap; - } -} diff --git a/src/Elements/New-TextareaElement.psm1 b/src/Elements/New-TextareaElement.psm1 new file mode 100644 index 0000000..7dd5684 --- /dev/null +++ b/src/Elements/New-TextareaElement.psm1 @@ -0,0 +1,132 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `textarea` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlTextareaElement"), Alias("textarea"), OutputType(typeof(string))] +function New-HtmlTextareaElementCommand(): NewElementCommand("textarea", isVoid: false) { + + <# + .SYNOPSIS + A hint for a user agent's autocomplete feature. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $AutoComplete = []; + + <# + .SYNOPSIS + Value indicating whether automatic spelling correction and processing of text is enabled. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("off", "on")] + [string] $AutoCorrect + + <# + .SYNOPSIS + The visible width of the text control, in average character widths. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + int Cols + + <# + .SYNOPSIS + The field name to use for sending the element's directionality in form submission. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $DirName + + <# + .SYNOPSIS + Value indicating whether to prevent the user from interacting with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Disabled + + <# + .SYNOPSIS + The identifier of a `form` element to associate with the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Form + + <# + .SYNOPSIS + The maximum string length that the user can enter. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int MaxLength = -1; + + <# + .SYNOPSIS + The minimum string length required that the user should enter. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int MinLength = -1; + + <# + .SYNOPSIS + The name of the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Name + + <# + .SYNOPSIS + A hint to the user of what can be entered in the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Placeholder + + <# + .SYNOPSIS + Value indicating whether the user cannot modify the value of the control. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $ReadOnly + + <# + .SYNOPSIS + Value indicating whether the user must fill in a value before submitting a form. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Required + + <# + .SYNOPSIS + The number of visible text lines for the control. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + int Rows + + <# + .SYNOPSIS + Value indicating whether the control should wrap the value for form submission. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("hard", "soft")] + [string] $Wrap + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); + if (AutoCorrect is not null) attributes["autocorrect"] = AutoCorrect; + if (Cols > 0) attributes["cols"] = Cols.ToString(CultureInfo.InvariantCulture); + if (!string.IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; + if (Disabled) attributes["disabled"] = true; + if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (MaxLength >= 0) attributes["maxlength"] = MaxLength.ToString(CultureInfo.InvariantCulture); + if (MinLength >= 0) attributes["minlength"] = MinLength.ToString(CultureInfo.InvariantCulture); + if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (!string.IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; + if (ReadOnly) attributes["readonly"] = true; + if (Required) attributes["required"] = true; + if (Rows > 0) attributes["rows"] = Rows.ToString(CultureInfo.InvariantCulture); + if (Wrap is not null) attributes["wrap"] = Wrap; + } +} diff --git a/src/Elements/New-ThElement.cs b/src/Elements/New-ThElement.cs deleted file mode 100644 index e8fd3f7..0000000 --- a/src/Elements/New-ThElement.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new th element. -/// -[Cmdlet(VerbsCommon.New, "HtmlThElement"), Alias("th"), OutputType(typeof(string))] -public class NewThElementCommand(): NewElementCommand("th", isVoid: false) { - - /// - /// A short, abbreviated description of the header cell's content provided as an alternative label to use for the header cell when referencing the cell in other contexts. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Abbr { get; set; } - - /// - /// An integer indicating how many columns the header cell spans or extends. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int ColSpan { get; set; } = -1; - - /// - /// A list of strings corresponding to the id attributes of the th elements that provide the headers for this header cell. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Headers { get; set; } = []; - - /// - /// An integer indicating how many rows the header cell spans or extends. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int RowSpan { get; set; } = -1; - - /// - /// Defines the cells that the header element relates to. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("col", "colgroup", "row", "rowgroup")] - public string? Scope { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Abbr)) attributes["abbr"] = Abbr; - if (ColSpan >= 0) attributes["colspan"] = ColSpan.ToString(CultureInfo.InvariantCulture); - if (Headers.Length > 0) attributes["headers"] = string.Join(' ', Headers).Trim(); - if (RowSpan >= 0) attributes["rowspan"] = RowSpan.ToString(CultureInfo.InvariantCulture); - if (Scope is not null) attributes["scope"] = Scope; - } -} diff --git a/src/Elements/New-ThElement.psm1 b/src/Elements/New-ThElement.psm1 new file mode 100644 index 0000000..dda87f9 --- /dev/null +++ b/src/Elements/New-ThElement.psm1 @@ -0,0 +1,59 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `th` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlThElement"), Alias("th"), OutputType(typeof(string))] +function New-HtmlThElementCommand(): NewElementCommand("th", isVoid: false) { + + <# + .SYNOPSIS + A short, abbreviated description of the header cell's content provided as an alternative label to use for the header cell when referencing the cell in other contexts. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Abbr + + <# + .SYNOPSIS + An integer indicating how many columns the header cell spans or extends. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int ColSpan = -1; + + <# + .SYNOPSIS + A list of strings corresponding to the `id` attributes of the `th` elements that provide the headers for this header cell. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Headers = []; + + <# + .SYNOPSIS + An integer indicating how many rows the header cell spans or extends. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int RowSpan = -1; + + <# + .SYNOPSIS + Defines the cells that the header element relates to. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("col", "colgroup", "row", "rowgroup")] + [string] $Scope + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (!string.IsNullOrWhiteSpace(Abbr)) attributes["abbr"] = Abbr; + if (ColSpan >= 0) attributes["colspan"] = ColSpan.ToString(CultureInfo.InvariantCulture); + if (Headers.Length > 0) attributes["headers"] = string.Join(' ', Headers).Trim(); + if (RowSpan >= 0) attributes["rowspan"] = RowSpan.ToString(CultureInfo.InvariantCulture); + if (Scope is not null) attributes["scope"] = Scope; + } +} diff --git a/src/Elements/New-TimeElement.cs b/src/Elements/New-TimeElement.psm1 similarity index 66% rename from src/Elements/New-TimeElement.cs rename to src/Elements/New-TimeElement.psm1 index 260771a..2d7649c 100644 --- a/src/Elements/New-TimeElement.cs +++ b/src/Elements/New-TimeElement.psm1 @@ -1,22 +1,23 @@ -namespace Belin.Html.Elements; - using System.Xml; -/// -/// Creates a new time element. -/// +<# +.SYNOPSIS + Creates a new `time` element. +#> [Cmdlet(VerbsCommon.New, "HtmlTimeElement"), Alias("time"), OutputType(typeof(string))] -public class NewTimeElementCommand(): NewElementCommand("time", isVoid: false) { +function New-HtmlTimeElementCommand(): NewElementCommand("time", isVoid: false) { - /// - /// The time and/or date of the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public object? DateTime { get; set; } + <# + .SYNOPSIS + The time and/or date of the element. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [object] $DateTime - /// - /// Populates the specified attribute collection with the element attributes. - /// + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); diff --git a/src/Elements/New-TrackElement.cs b/src/Elements/New-TrackElement.cs deleted file mode 100644 index 97df30e..0000000 --- a/src/Elements/New-TrackElement.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new track element. -/// -[Cmdlet(VerbsCommon.New, "HtmlTrackElement"), Alias("track"), OutputType(typeof(string))] -public class NewTrackElementCommand(): NewElementCommand("track", isVoid: true) { - - /// - /// Value indicating whether the track should be enabled unless the user's preferences indicate that another track is more appropriate. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Default { get; set; } - - /// - /// Value indicating how the text track is meant to be used. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("captions", "chapters", "descriptions", "metadata", "subtitles")] - public string? Kind { get; set; } - - /// - /// A user-readable title of the text track which is used by the browser when listing available text tracks. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Label { get; set; } - - /// - /// The address of the track (.vtt file). - /// - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] - public required Uri Src { get; set; } - - /// - /// The language of the track text data. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public CultureInfo? SrcLang { get; set; } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["src"] = Src.ToString(); - if (Default) attributes["default"] = true; - if (Kind is not null) attributes["kind"] = Kind; - if (!string.IsNullOrWhiteSpace(Label)) attributes["label"] = Label; - if (SrcLang is not null) attributes["srclang"] = SrcLang.Name; - } -} diff --git a/src/Elements/New-TrackElement.psm1 b/src/Elements/New-TrackElement.psm1 new file mode 100644 index 0000000..52943c2 --- /dev/null +++ b/src/Elements/New-TrackElement.psm1 @@ -0,0 +1,59 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `track` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlTrackElement"), Alias("track"), OutputType(typeof(string))] +function New-HtmlTrackElementCommand(): NewElementCommand("track", isVoid: true) { + + <# + .SYNOPSIS + Value indicating whether the track should be enabled unless the user's preferences indicate that another track is more appropriate. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Default + + <# + .SYNOPSIS + Value indicating how the text track is meant to be used. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("captions", "chapters", "descriptions", "metadata", "subtitles")] + [string] $Kind + + <# + .SYNOPSIS + A user-readable title of the text track which is used by the browser when listing available text tracks. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Label + + <# + .SYNOPSIS + The address of the track (`.vtt` file). + #> + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + required Uri Src + + <# + .SYNOPSIS + The language of the track text data. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [cultureinfo] $SrcLang + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + attributes["src"] = Src.ToString(); + if (Default) attributes["default"] = true; + if (Kind is not null) attributes["kind"] = Kind; + if (!string.IsNullOrWhiteSpace(Label)) attributes["label"] = Label; + if (SrcLang is not null) attributes["srclang"] = SrcLang.Name; + } +} diff --git a/src/Elements/New-VideoElement.cs b/src/Elements/New-VideoElement.cs deleted file mode 100644 index c904aef..0000000 --- a/src/Elements/New-VideoElement.cs +++ /dev/null @@ -1,109 +0,0 @@ -namespace Belin.Html.Elements; - -using System.Globalization; - -/// -/// Creates a new video element. -/// -[Cmdlet(VerbsCommon.New, "HtmlVideoElement"), Alias("video"), OutputType(typeof(string))] -public class NewVideoElementCommand(): NewElementCommand("video", isVoid: false) { - - /// - /// Value indicating whether playback should start automatically as soon as the video signal allows. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter AutoPlay { get; set; } - - /// - /// Value indicating whether to offer controls to allow the user to control video playback. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Controls { get; set; } - - /// - /// Value indicating whether CORS must be used when fetching the resource. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("anonymous", "use-credentials")] - public string? CrossOrigin { get; set; } - - /// - /// Value indicating whether to prevent the browser from suggesting a Picture-in-Picture context menu or to request Picture-in-Picture automatically. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter DisablePictureInPicture { get; set; } - - /// - /// Value indicating whether to disable the capability of remote playback in devices that are attached using wired and wireless technologies. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter DisableRemotePlayback { get; set; } - - /// - /// The height of the video's display area, in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Height { get; set; } = -1; - - /// - /// Value indicating whether the video player will automatically seek back to the start upon reaching the end of the video. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Loop { get; set; } - - /// - /// Value indicating whether the audio will be initially silenced. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Muted { get; set; } - - /// - /// Value indicating whether the video is to be played "inline", that is, within the element's playback area. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter PlaysInline { get; set; } - - /// - /// The URL for an image to be shown while the video is downloading. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Poster { get; set; } - - /// - /// Value providing a hint to the browser about what the author thinks will lead to the best user experience. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("auto", "none", "metadata")] - public string? Preload { get; set; } - - /// - /// The URL of the video to embed. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Uri? Src { get; set; } - - /// - /// The width of the video's display area, in CSS pixels. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateRange(ValidateRangeKind.NonNegative)] - public int Width { get; set; } = -1; - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - if (AutoPlay) attributes["autoplay"] = true; - if (Controls) attributes["controls"] = true; - if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (DisablePictureInPicture) attributes["disablepictureinpicture"] = true; - if (DisableRemotePlayback) attributes["disableremoteplayback"] = true; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (Loop) attributes["loop"] = true; - if (Muted) attributes["muted"] = true; - if (PlaysInline) attributes["playsinline"] = true; - if (Poster is not null) attributes["poster"] = Poster.ToString(); - if (Preload is not null) attributes["preload"] = Preload; - if (Src is not null) attributes["src"] = Src.ToString(); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); - } -} diff --git a/src/Elements/New-VideoElement.psm1 b/src/Elements/New-VideoElement.psm1 new file mode 100644 index 0000000..c14a25b --- /dev/null +++ b/src/Elements/New-VideoElement.psm1 @@ -0,0 +1,124 @@ +using System.Globalization; + +<# +.SYNOPSIS + Creates a new `video` element. +#> +[Cmdlet(VerbsCommon.New, "HtmlVideoElement"), Alias("video"), OutputType(typeof(string))] +function New-HtmlVideoElementCommand(): NewElementCommand("video", isVoid: false) { + + <# + .SYNOPSIS + Value indicating whether playback should start automatically as soon as the video signal allows. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $AutoPlay + + <# + .SYNOPSIS + Value indicating whether to offer controls to allow the user to control video playback. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Controls + + <# + .SYNOPSIS + Value indicating whether CORS must be used when fetching the resource. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("anonymous", "use-credentials")] + [string] $CrossOrigin + + <# + .SYNOPSIS + Value indicating whether to prevent the browser from suggesting a Picture-in-Picture context menu or to request Picture-in-Picture automatically. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $DisablePictureInPicture + + <# + .SYNOPSIS + Value indicating whether to disable the capability of remote playback in devices that are attached using wired and wireless technologies. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $DisableRemotePlayback + + <# + .SYNOPSIS + The height of the video's display area, in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Height = -1; + + <# + .SYNOPSIS + Value indicating whether the video player will automatically seek back to the start upon reaching the end of the video. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Loop + + <# + .SYNOPSIS + Value indicating whether the audio will be initially silenced. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $Muted + + <# + .SYNOPSIS + Value indicating whether the video is to be played "inline", that is, within the element's playback area. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [switch] $PlaysInline + + <# + .SYNOPSIS + The URL for an image to be shown while the video is downloading. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Poster + + <# + .SYNOPSIS + Value providing a hint to the browser about what the author thinks will lead to the best user experience. + #> + [Parameter(ValueFromPipelineByPropertyName)] + [ValidateSet("auto", "none", "metadata")] + [string] $Preload + + <# + .SYNOPSIS + The URL of the video to embed. + #> + [Parameter(ValueFromPipelineByPropertyName)] + Uri? Src + + <# + .SYNOPSIS + The width of the video's display area, in CSS pixels. + #> + [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + int Width = -1; + + <# + .SYNOPSIS + Populates the specified attribute collection with the element attributes. + #> + /// The attribute collection to populate. + protected override void RenderAttributes(IDictionary attributes) { + base.RenderAttributes(attributes); + if (AutoPlay) attributes["autoplay"] = true; + if (Controls) attributes["controls"] = true; + if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; + if (DisablePictureInPicture) attributes["disablepictureinpicture"] = true; + if (DisableRemotePlayback) attributes["disableremoteplayback"] = true; + if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (Loop) attributes["loop"] = true; + if (Muted) attributes["muted"] = true; + if (PlaysInline) attributes["playsinline"] = true; + if (Poster is not null) attributes["poster"] = Poster.ToString(); + if (Preload is not null) attributes["preload"] = Preload; + if (Src is not null) attributes["src"] = Src.ToString(); + if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + } +} From 0ae6416dcae9effdab0ace4a2769711ec6b0747d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 13:45:51 +0200 Subject: [PATCH 13/23] Update the "Clean" script --- tool/Clean.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tool/Clean.ps1 b/tool/Clean.ps1 index af77604..e463583 100644 --- a/tool/Clean.ps1 +++ b/tool/Clean.ps1 @@ -1,2 +1,3 @@ "Deleting all generated files..." +Remove-Item src/Generated -ErrorAction Ignore -Force -Recurse Remove-Item var/* -Exclude .gitkeep -Force -Recurse From 6467c4fac82333cc4c2f64309bfe9d1c02d0b3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 13:51:04 +0200 Subject: [PATCH 14/23] Update the build system [skip ci] --- Html.psd1 | 344 +++++++++++++++++++++++++++++++++++++++++++++-- tool/Assets.ps1 | 28 ---- tool/Build.ps1 | 73 ++++++++++ tool/Default.ps1 | 1 + 4 files changed, 410 insertions(+), 36 deletions(-) delete mode 100644 tool/Assets.ps1 create mode 100644 tool/Build.ps1 diff --git a/Html.psd1 b/Html.psd1 index 91f5bdb..63dabc1 100644 --- a/Html.psd1 +++ b/Html.psd1 @@ -13,20 +13,348 @@ VariablesToExport = @() AliasesToExport = @( - "doctype" - "layout" + "a" + "abbr" + "address" + "area" + "article" + "aside" + "audio" + "b" + "base" + "bdi" + "bdo" + "blockquote" + "body" + "br" + "button" + "canvas" + "caption" + "cite" + "code" + "col" + "colgroup" + "data" + "datalist" + "dd" + "delTag" + "details" + "dfn" + "dialog" + "div" + "dl" + "dt" + "em" + "embed" + "fieldset" + "figcaption" + "figure" + "footer" + "form" + "h1" + "h2" + "h3" + "h4" + "h5" + "h6" + "head" + "header" + "hgroup" + "hr" + "html" + "i" + "iframe" + "img" + "input" + "ins" + "kbd" + "label" + "legend" + "li" + "link" + "main" + "map" + "mark" + "menu" + "meta" + "meter" + "nav" + "noscript" + "object" + "ol" + "optgroup" + "option" + "output" + "p" + "picture" + "pre" + "progress" + "q" + "rpTag" + "rt" + "ruby" + "s" + "samp" + "script" + "search" + "section" + "selectTag" + "slot" + "small" + "source" + "span" + "strong" + "style" + "sub" + "summary" + "sup" + "table" + "tbody" + "td" + "template" + "textarea" + "tfoot" + "th" + "thead" + "time" + "title" + "tr" + "track" + "u" + "ul" + "var" + "video" + "wbr" ) FunctionsToExport = @( - "New-HtmlDocumentType" - "Use-HtmlLayout" - "Write-HtmlView" + "New-HtmlAbbrElement" + "New-HtmlAddressElement" + "New-HtmlAElement" + "New-HtmlAreaElement" + "New-HtmlArticleElement" + "New-HtmlAsideElement" + "New-HtmlAudioElement" + "New-HtmlBaseElement" + "New-HtmlBdiElement" + "New-HtmlBdoElement" + "New-HtmlBElement" + "New-HtmlBlockquoteElement" + "New-HtmlBodyElement" + "New-HtmlBrElement" + "New-HtmlButtonElement" + "New-HtmlCanvasElement" + "New-HtmlCaptionElement" + "New-HtmlCiteElement" + "New-HtmlCodeElement" + "New-HtmlColElement" + "New-HtmlColgroupElement" + "New-HtmlDataElement" + "New-HtmlDatalistElement" + "New-HtmlDdElement" + "New-HtmlDelElement" + "New-HtmlDetailsElement" + "New-HtmlDfnElement" + "New-HtmlDialogElement" + "New-HtmlDivElement" + "New-HtmlDlElement" + "New-HtmlDtElement" + "New-HtmlEmbedElement" + "New-HtmlEmElement" + "New-HtmlFieldsetElement" + "New-HtmlFigcaptionElement" + "New-HtmlFigureElement" + "New-HtmlFooterElement" + "New-HtmlFormElement" + "New-HtmlH1Element" + "New-HtmlH2Element" + "New-HtmlH3Element" + "New-HtmlH4Element" + "New-HtmlH5Element" + "New-HtmlH6Element" + "New-HtmlHeadElement" + "New-HtmlHeaderElement" + "New-HtmlHgroupElement" + "New-HtmlHrElement" + "New-HtmlHtmlElement" + "New-HtmlIElement" + "New-HtmlIframeElement" + "New-HtmlImgElement" + "New-HtmlInputElement" + "New-HtmlInsElement" + "New-HtmlKbdElement" + "New-HtmlLabelElement" + "New-HtmlLegendElement" + "New-HtmlLiElement" + "New-HtmlLinkElement" + "New-HtmlMainElement" + "New-HtmlMapElement" + "New-HtmlMarkElement" + "New-HtmlMenuElement" + "New-HtmlMetaElement" + "New-HtmlMeterElement" + "New-HtmlNavElement" + "New-HtmlNoscriptElement" + "New-HtmlObjectElement" + "New-HtmlOlElement" + "New-HtmlOptgroupElement" + "New-HtmlOptionElement" + "New-HtmlOutputElement" + "New-HtmlPElement" + "New-HtmlPictureElement" + "New-HtmlPreElement" + "New-HtmlProgressElement" + "New-HtmlQElement" + "New-HtmlRpElement" + "New-HtmlRtElement" + "New-HtmlRubyElement" + "New-HtmlSampElement" + "New-HtmlScriptElement" + "New-HtmlSearchElement" + "New-HtmlSectionElement" + "New-HtmlSelectElement" + "New-HtmlSElement" + "New-HtmlSlotElement" + "New-HtmlSmallElement" + "New-HtmlSourceElement" + "New-HtmlSpanElement" + "New-HtmlStrongElement" + "New-HtmlStyleElement" + "New-HtmlSubElement" + "New-HtmlSummaryElement" + "New-HtmlSupElement" + "New-HtmlTableElement" + "New-HtmlTbodyElement" + "New-HtmlTdElement" + "New-HtmlTemplateElement" + "New-HtmlTextareaElement" + "New-HtmlTfootElement" + "New-HtmlTheadElement" + "New-HtmlThElement" + "New-HtmlTimeElement" + "New-HtmlTitleElement" + "New-HtmlTrackElement" + "New-HtmlTrElement" + "New-HtmlUElement" + "New-HtmlUlElement" + "New-HtmlVarElement" + "New-HtmlVideoElement" + "New-HtmlWbrElement" ) NestedModules = @( - "src/New-DocumentType.psm1" - "src/Use-Layout.psm1" - "src/Write-View.psm1" + "src/Elements/New-AElement.psm1" + "src/Elements/New-AreaElement.psm1" + "src/Elements/New-AudioElement.psm1" + "src/Elements/New-BaseElement.psm1" + "src/Elements/New-BlockquoteElement.psm1" + "src/Elements/New-ButtonElement.psm1" + "src/Elements/New-CanvasElement.psm1" + "src/Elements/New-ColElement.psm1" + "src/Elements/New-ColgroupElement.psm1" + "src/Elements/New-DataElement.psm1" + "src/Elements/New-DelElement.psm1" + "src/Elements/New-DetailsElement.psm1" + "src/Elements/New-DialogElement.psm1" + "src/Elements/New-EmbedElement.psm1" + "src/Elements/New-FieldsetElement.psm1" + "src/Elements/New-FormElement.psm1" + "src/Elements/New-IframeElement.psm1" + "src/Elements/New-ImgElement.psm1" + "src/Elements/New-InputElement.psm1" + "src/Elements/New-InsElement.psm1" + "src/Elements/New-LabelElement.psm1" + "src/Elements/New-LiElement.psm1" + "src/Elements/New-LinkElement.psm1" + "src/Elements/New-MapElement.psm1" + "src/Elements/New-MetaElement.psm1" + "src/Elements/New-MeterElement.psm1" + "src/Elements/New-ObjectElement.psm1" + "src/Elements/New-OlElement.psm1" + "src/Elements/New-OptgroupElement.psm1" + "src/Elements/New-OptionElement.psm1" + "src/Elements/New-OutputElement.psm1" + "src/Elements/New-ProgressElement.psm1" + "src/Elements/New-QElement.psm1" + "src/Elements/New-ScriptElement.psm1" + "src/Elements/New-SelectElement.psm1" + "src/Elements/New-SlotElement.psm1" + "src/Elements/New-SourceElement.psm1" + "src/Elements/New-StyleElement.psm1" + "src/Elements/New-TdElement.psm1" + "src/Elements/New-TemplateElement.psm1" + "src/Elements/New-TextareaElement.psm1" + "src/Elements/New-ThElement.psm1" + "src/Elements/New-TimeElement.psm1" + "src/Elements/New-TrackElement.psm1" + "src/Elements/New-VideoElement.psm1" + "src/Generated/New-AbbrElement.g.psm1" + "src/Generated/New-AddressElement.g.psm1" + "src/Generated/New-ArticleElement.g.psm1" + "src/Generated/New-AsideElement.g.psm1" + "src/Generated/New-BdiElement.g.psm1" + "src/Generated/New-BdoElement.g.psm1" + "src/Generated/New-BElement.g.psm1" + "src/Generated/New-BodyElement.g.psm1" + "src/Generated/New-BrElement.g.psm1" + "src/Generated/New-CaptionElement.g.psm1" + "src/Generated/New-CiteElement.g.psm1" + "src/Generated/New-CodeElement.g.psm1" + "src/Generated/New-DatalistElement.g.psm1" + "src/Generated/New-DdElement.g.psm1" + "src/Generated/New-DfnElement.g.psm1" + "src/Generated/New-DivElement.g.psm1" + "src/Generated/New-DlElement.g.psm1" + "src/Generated/New-DtElement.g.psm1" + "src/Generated/New-EmElement.g.psm1" + "src/Generated/New-FigcaptionElement.g.psm1" + "src/Generated/New-FigureElement.g.psm1" + "src/Generated/New-FooterElement.g.psm1" + "src/Generated/New-H1Element.g.psm1" + "src/Generated/New-H2Element.g.psm1" + "src/Generated/New-H3Element.g.psm1" + "src/Generated/New-H4Element.g.psm1" + "src/Generated/New-H5Element.g.psm1" + "src/Generated/New-H6Element.g.psm1" + "src/Generated/New-HeadElement.g.psm1" + "src/Generated/New-HeaderElement.g.psm1" + "src/Generated/New-HgroupElement.g.psm1" + "src/Generated/New-HrElement.g.psm1" + "src/Generated/New-HtmlElement.g.psm1" + "src/Generated/New-IElement.g.psm1" + "src/Generated/New-KbdElement.g.psm1" + "src/Generated/New-LegendElement.g.psm1" + "src/Generated/New-MainElement.g.psm1" + "src/Generated/New-MarkElement.g.psm1" + "src/Generated/New-MenuElement.g.psm1" + "src/Generated/New-NavElement.g.psm1" + "src/Generated/New-NoscriptElement.g.psm1" + "src/Generated/New-PElement.g.psm1" + "src/Generated/New-PictureElement.g.psm1" + "src/Generated/New-PreElement.g.psm1" + "src/Generated/New-RpElement.g.psm1" + "src/Generated/New-RtElement.g.psm1" + "src/Generated/New-RubyElement.g.psm1" + "src/Generated/New-SampElement.g.psm1" + "src/Generated/New-SearchElement.g.psm1" + "src/Generated/New-SectionElement.g.psm1" + "src/Generated/New-SElement.g.psm1" + "src/Generated/New-SmallElement.g.psm1" + "src/Generated/New-SpanElement.g.psm1" + "src/Generated/New-StrongElement.g.psm1" + "src/Generated/New-SubElement.g.psm1" + "src/Generated/New-SummaryElement.g.psm1" + "src/Generated/New-SupElement.g.psm1" + "src/Generated/New-TableElement.g.psm1" + "src/Generated/New-TbodyElement.g.psm1" + "src/Generated/New-TfootElement.g.psm1" + "src/Generated/New-TheadElement.g.psm1" + "src/Generated/New-TitleElement.g.psm1" + "src/Generated/New-TrElement.g.psm1" + "src/Generated/New-UElement.g.psm1" + "src/Generated/New-UlElement.g.psm1" + "src/Generated/New-VarElement.g.psm1" + "src/Generated/New-WbrElement.g.psm1" ) PrivateData = @{ diff --git a/tool/Assets.ps1 b/tool/Assets.ps1 deleted file mode 100644 index d0b9068..0000000 --- a/tool/Assets.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -using namespace System.Collections.Generic - -"Deploying the assets..." -$cmdletTemplate = Get-Content share/Cmdlet.Template.cs -Raw -$cmdletsToExport = [List[string]]::new([string[]] @("New-HtmlCustomElement")) - -New-Item src/Generated -Force -ItemType Directory | Out-Null -foreach ($element in (Import-PowerShellDataFile share/HtmlElements.psd1).Elements) { - $parameters = @{ - Alias = (Get-Alias $element.Tag -ErrorAction Ignore) ? "$($element.Tag)Tag" : $element.Tag - CapitalizedTag = [char]::ToUpperInvariant($element.Tag[0]) + $element.Tag.Substring(1) - IsVoid = $element.IsVoid.ToString().ToLowerInvariant() - Tag = $element.Tag - } - - $cmdletsToExport.Add("New-Html$($parameters.CapitalizedTag)Element") - $fileName = "New-$($parameters.CapitalizedTag)Element" - if (Test-Path "src/Elements/$fileName.psm1") { continue } - - $content = $cmdletTemplate - foreach ($key in $parameters.Keys) { $content = $content -replace "{$key}", $parameters.$key } - Set-Content "src/Generated/$fileName.g.psm1" $content -NoNewline -} - -$cmdletsToExport.Sort() -$cmdlets = $cmdletsToExport.PSForEach{ "`t`t""$_""" } -join [Environment]::NewLine -$content = (Get-Content Html.psd1 -Raw) -replace "CmdletsToExport = @\([^)]+\)", "CmdletsToExport = @(`n$cmdlets`n`t)" -Set-Content Html.psd1 $content -NoNewline diff --git a/tool/Build.ps1 b/tool/Build.ps1 new file mode 100644 index 0000000..8ad44c6 --- /dev/null +++ b/tool/Build.ps1 @@ -0,0 +1,73 @@ +using namespace System.Collections.Generic + +"Deploying the assets..." +$cmdlets = [pscustomobject]@{ + Aliases = [List[string]]::new() + Functions = [List[string]]::new() + Modules = [List[string]]::new() +} + +$cmdlets.Aliases = [List[string]]::new([string[]] @( + # "doctype" + # "layout" + # "tag" +)) + +$cmdlets.Functions = [List[string]]::new([string[]] @( + # "New-HtmlCustomElement" + # "New-HtmlDocumentType" + # "Use-HtmlLayout" + # "Write-HtmlView" +)) + +$cmdlets.Modules = [List[string]]::new([string[]] @( + # "src/New-CustomElement.psm1" + # "src/New-DocumentType.psm1" + # "src/Use-Layout.psm1" + # "src/Write-View.psm1" +)) + +# Generate the cmdlets. +New-Item src/Generated -Force -ItemType Directory | Out-Null +$cmdletTemplate = Get-Content share/Cmdlet.Template.psm1 -Raw + +foreach ($element in (Import-PowerShellDataFile share/HtmlElements.psd1).Elements) { + $parameters = @{ + Alias = (Get-Alias $element.Tag -ErrorAction Ignore) ? "$($element.Tag)Tag" : $element.Tag + CapitalizedTag = [char]::ToUpperInvariant($element.Tag[0]) + $element.Tag.Substring(1) + IsVoid = $element.IsVoid.ToString().ToLowerInvariant() + Tag = $element.Tag + } + + $cmdlets.Aliases.Add($parameters.Alias) + $cmdlets.Functions.Add("New-Html$($parameters.CapitalizedTag)Element") + + $fileName = "New-$($parameters.CapitalizedTag)Element" + $existingCmdlet = "src/Elements/$fileName.psm1" + if (Test-Path $existingCmdlet) { $cmdlets.Modules.Add($existingCmdlet) } + else { + $generatedCmdlet = "src/Generated/$fileName.g.psm1" + $cmdlets.Modules.Add($generatedCmdlet) + + $content = $cmdletTemplate + foreach ($key in $parameters.Keys) { $content = $content -replace "{$key}", $parameters.$key } + Set-Content $generatedCmdlet $content -NoNewline + } +} + +# Update the module manifest. +$cmdlets.Aliases.Sort() +$aliases = $cmdlets.Aliases.PSForEach{ "`t`t""$_""" } -join [Environment]::NewLine + +$cmdlets.Functions.Sort() +$functions = $cmdlets.Functions.PSForEach{ "`t`t""$_""" } -join [Environment]::NewLine + +$cmdlets.Modules.Sort() +$modules = $cmdlets.Modules.PSForEach{ "`t`t""$_""" } -join [Environment]::NewLine + +$content = (Get-Content Html.psd1 -Raw) ` + -replace "AliasesToExport = @\([^)]+\)", "AliasesToExport = @(`n$aliases`n`t)" ` + -replace "FunctionsToExport = @\([^)]+\)", "FunctionsToExport = @(`n$functions`n`t)" ` + -replace "NestedModules = @\([^)]+\)", "NestedModules = @(`n$modules`n`t)" + +Set-Content Html.psd1 $content -NoNewline diff --git a/tool/Default.ps1 b/tool/Default.ps1 index 4e1a44f..df4ed3b 100644 --- a/tool/Default.ps1 +++ b/tool/Default.ps1 @@ -1 +1,2 @@ & "$PSScriptRoot/Clean.ps1" +& "$PSScriptRoot/Build.ps1" From 87542455c62142d66fd4a362970117859f57b657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 14:49:27 +0200 Subject: [PATCH 15/23] Port the `New-HtmlAElement` cmdlet --- src/Elements/New-AElement.psm1 | 97 ++++++++++++------------- src/Elements/New-AreaElement.psm1 | 14 ++-- src/Elements/New-AudioElement.psm1 | 4 +- src/Elements/New-BaseElement.psm1 | 8 +- src/Elements/New-BlockquoteElement.psm1 | 4 +- src/Elements/New-ButtonElement.psm1 | 17 +++-- src/Elements/New-CanvasElement.psm1 | 8 +- src/Elements/New-ColElement.psm1 | 6 +- src/Elements/New-ColGroupElement.psm1 | 6 +- src/Elements/New-DataElement.psm1 | 6 +- src/Elements/New-DelElement.psm1 | 4 +- src/Elements/New-DetailsElement.psm1 | 6 +- src/Elements/New-DialogElement.psm1 | 4 +- src/Elements/New-EmbedElement.psm1 | 12 +-- src/Elements/New-FieldsetElement.psm1 | 8 +- src/Elements/New-FormElement.psm1 | 11 +-- src/Elements/New-IframeElement.psm1 | 16 ++-- src/Elements/New-ImgElement.psm1 | 16 ++-- src/Elements/New-InputElement.psm1 | 41 +++++------ src/Elements/New-InsElement.psm1 | 4 +- src/Elements/New-LabelElement.psm1 | 6 +- src/Elements/New-LiElement.psm1 | 6 +- src/Elements/New-LinkElement.psm1 | 18 +++-- src/Elements/New-MapElement.psm1 | 6 +- src/Elements/New-MetaElement.psm1 | 14 ++-- src/Elements/New-MeterElement.psm1 | 16 ++-- src/Elements/New-ObjectElement.psm1 | 16 ++-- src/Elements/New-OlElement.psm1 | 6 +- src/Elements/New-OptgroupElement.psm1 | 4 +- src/Elements/New-OptionElement.psm1 | 6 +- src/Elements/New-OutputElement.psm1 | 10 ++- src/Elements/New-ProgressElement.psm1 | 8 +- src/Elements/New-QElement.psm1 | 4 +- src/Elements/New-ScriptElement.psm1 | 8 +- src/Elements/New-SelectElement.psm1 | 12 +-- src/Elements/New-SlotElement.psm1 | 6 +- src/Elements/New-SourceElement.psm1 | 20 ++--- src/Elements/New-StyleElement.psm1 | 6 +- src/Elements/New-TdElement.psm1 | 10 +-- src/Elements/New-TemplateElement.psm1 | 4 +- src/Elements/New-TextareaElement.psm1 | 22 +++--- src/Elements/New-ThElement.psm1 | 12 +-- src/Elements/New-TimeElement.psm1 | 5 +- src/Elements/New-TrackElement.psm1 | 8 +- src/Elements/New-VideoElement.psm1 | 8 +- 45 files changed, 287 insertions(+), 246 deletions(-) diff --git a/src/Elements/New-AElement.psm1 b/src/Elements/New-AElement.psm1 index 64a8610..5aa751c 100644 --- a/src/Elements/New-AElement.psm1 +++ b/src/Elements/New-AElement.psm1 @@ -1,56 +1,53 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `a` element. +.INPUTS + The inner HTML of the `a` element. +.OUTPUTS + The newly created `a` element. #> -[Cmdlet(VerbsCommon.New, "HtmlAElement"), Alias("a"), OutputType(typeof(string))] -function New-HtmlAElementCommand(): NewElementCommand("a", isVoid: false) { - - <# - .SYNOPSIS - The suggested filename when the browser treats the linked URL as a download. - #> - [Parameter(ValueFromPipelineByPropertyName)] - [string] $Download - - <# - .SYNOPSIS - The URL that the hyperlink points to. - #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] - [uri] $Href - - <# - .SYNOPSIS - A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. - #> - [Parameter(ValueFromPipelineByPropertyName)] - [uri[]] $Ping = []; - - <# - .SYNOPSIS - The relationship of the linked URL. - #> - [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $Rel = []; - - <# - .SYNOPSIS - The browsing context to show the results of navigation. - #> - [Parameter(ValueFromPipelineByPropertyName)] - [string] $Target - - <# - .SYNOPSIS - Populates the specified attribute collection with the element attributes. - #> - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["href"] = Href.ToString(); - if (!string.IsNullOrWhiteSpace(Download)) attributes["download"] = Download; - if (Ping.Length > 0) attributes["ping"] = string.Join(' ', Ping.Select(url => url.ToString())).Trim(); - if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); - if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; +function New-HtmlAElement { + [Alias("a")] + [CmdletBinding()] + [OutputType([string])] + param ( + # The custom attributes to render. + [Parameter(ValueFromPipelineByPropertyName)] + [hashtable] $Attributes = @{}, + + # The suggested filename when the browser treats the linked URL as a download. + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Download, + + # The URL that the hyperlink points to. + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [uri] $Href, + + # A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. + [Parameter(ValueFromPipelineByPropertyName)] + [uri[]] $Ping = @(), + + # The relationship of the linked URL. + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] $Rel = @(), + + # The browsing context to show the results of navigation. + [Parameter(ValueFromPipelineByPropertyName)] + [string] $Target + ) + + process { + $attributesToRender = $Attributes.Clone() + $attributesToRender.href = $Href + if ($Download) { $attributesToRender.download = $Download } + if ($Ping) { $attributesToRender.ping = ($Ping -join " ").Trim() } + if ($Rel) { $attributesToRender.rel = ($Rel -join " ").Trim() } + if ($Target) { $attributesToRender.target = $Target } + + $parameters = $PSBoundParameters.Clone() + $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $parameters.Remove($_) } + New-Element -Attributes $attributesToRender @parameters } } diff --git a/src/Elements/New-AreaElement.psm1 b/src/Elements/New-AreaElement.psm1 index f34b4f1..d8f2d76 100644 --- a/src/Elements/New-AreaElement.psm1 +++ b/src/Elements/New-AreaElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `area` element. #> [Cmdlet(VerbsCommon.New, "HtmlAreaElement"), Alias("area"), OutputType(typeof(string))] -function New-HtmlAreaElementCommand(): NewElementCommand("area", isVoid: true) { +function New-HtmlAreaElement: NewElementCommand("area", isVoid: true) { <# .SYNOPSIS @@ -32,7 +32,7 @@ function New-HtmlAreaElementCommand(): NewElementCommand("area", isVoid: true) { .SYNOPSIS The hyperlink target for the area. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [uri] $Href <# @@ -40,14 +40,14 @@ function New-HtmlAreaElementCommand(): NewElementCommand("area", isVoid: true) { A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. #> [Parameter(ValueFromPipelineByPropertyName)] - [uri[]] $Ping = []; + [uri[]] $Ping = @(), <# .SYNOPSIS The relationship of the linked URL. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $Rel = []; + [string[]] $Rel = @(), <# .SYNOPSIS @@ -79,9 +79,9 @@ function New-HtmlAreaElementCommand(): NewElementCommand("area", isVoid: true) { } if (Alt is not null) attributes["alt"] = Alt; - if (!string.IsNullOrWhiteSpace(Download)) attributes["download"] = Download; + if (-not [string]::IsNullOrWhiteSpace(Download)) attributes["download"] = Download; if (Ping.Length > 0) attributes["ping"] = string.Join(' ', Ping.Select(url => url.ToString())).Trim(); if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); - if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + if (-not [string]::IsNullOrWhiteSpace(Target)) attributes["target"] = Target; } } diff --git a/src/Elements/New-AudioElement.psm1 b/src/Elements/New-AudioElement.psm1 index a5d90ef..3778ee4 100644 --- a/src/Elements/New-AudioElement.psm1 +++ b/src/Elements/New-AudioElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `audio` element. #> [Cmdlet(VerbsCommon.New, "HtmlAudioElement"), Alias("audio"), OutputType(typeof(string))] -function New-HtmlAudioElementCommand(): NewElementCommand("audio", isVoid: false) { +function New-HtmlAudioElement: NewElementCommand("audio", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-BaseElement.psm1 b/src/Elements/New-BaseElement.psm1 index a32e53d..1747ba4 100644 --- a/src/Elements/New-BaseElement.psm1 +++ b/src/Elements/New-BaseElement.psm1 @@ -1,15 +1,17 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `base` element. #> [Cmdlet(VerbsCommon.New, "HtmlBaseElement"), Alias("base"), OutputType(typeof(string))] -function New-HtmlBaseElementCommand(): NewElementCommand("base", isVoid: true) { +function New-HtmlBaseElement: NewElementCommand("base", isVoid: true) { <# .SYNOPSIS The base URL to be used throughout the document for relative URLs. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [uri] $Href <# @@ -27,6 +29,6 @@ function New-HtmlBaseElementCommand(): NewElementCommand("base", isVoid: true) { protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); attributes["href"] = Href.ToString(); - if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + if (-not [string]::IsNullOrWhiteSpace(Target)) attributes["target"] = Target; } } diff --git a/src/Elements/New-BlockquoteElement.psm1 b/src/Elements/New-BlockquoteElement.psm1 index 0db5b77..745a292 100644 --- a/src/Elements/New-BlockquoteElement.psm1 +++ b/src/Elements/New-BlockquoteElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `blockquote` element. #> [Cmdlet(VerbsCommon.New, "HtmlBlockquoteElement"), Alias("blockquote"), OutputType(typeof(string))] -function New-HtmlBlockquoteElementCommand(): NewElementCommand("blockquote", isVoid: false) { +function New-HtmlBlockquoteElement: NewElementCommand("blockquote", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-ButtonElement.psm1 b/src/Elements/New-ButtonElement.psm1 index 9cb54d8..e2e8fb6 100644 --- a/src/Elements/New-ButtonElement.psm1 +++ b/src/Elements/New-ButtonElement.psm1 @@ -1,11 +1,12 @@ -using System.Net.Mime; +using namespace System.Net.Mime +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `button` element. #> [Cmdlet(VerbsCommon.New, "HtmlButtonElement"), Alias("button"), OutputType(typeof(string))] -function New-HtmlButtonElementCommand(): NewElementCommand("button", isVoid: false) { +function New-HtmlButtonElement: NewElementCommand("button", isVoid: false) { <# .SYNOPSIS @@ -116,17 +117,17 @@ function New-HtmlButtonElementCommand(): NewElementCommand("button", isVoid: fal /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Command)) attributes["command"] = Command; - if (!string.IsNullOrWhiteSpace(CommandFor)) attributes["commandfor"] = CommandFor; + if (-not [string]::IsNullOrWhiteSpace(Command)) attributes["command"] = Command; + if (-not [string]::IsNullOrWhiteSpace(CommandFor)) attributes["commandfor"] = CommandFor; if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; if (FormAction is not null) attributes["formaction"] = FormAction.ToString(); if (FormEnctype is not null) attributes["formenctype"] = FormEnctype; if (FormMethod is not null) attributes["formmethod"] = FormMethod; if (FormNoValidate) attributes["formnovalidate"] = true; - if (!string.IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (!string.IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; + if (-not [string]::IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; if (PopoverTargetAction is not null) attributes["popovertargetaction"] = PopoverTargetAction; if (Type is not null) attributes["type"] = Type; if (Value is not null) attributes["value"] = Value; diff --git a/src/Elements/New-CanvasElement.psm1 b/src/Elements/New-CanvasElement.psm1 index 1363dbd..d411e8d 100644 --- a/src/Elements/New-CanvasElement.psm1 +++ b/src/Elements/New-CanvasElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `canvas` element. #> [Cmdlet(VerbsCommon.New, "HtmlCanvasElement"), Alias("canvas"), OutputType(typeof(string))] -function New-HtmlCanvasElementCommand(): NewElementCommand("canvas", isVoid: false) { +function New-HtmlCanvasElement: NewElementCommand("canvas", isVoid: false) { <# .SYNOPSIS @@ -28,7 +28,7 @@ function New-HtmlCanvasElementCommand(): NewElementCommand("canvas", isVoid: fal /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + if (Height >= 0) attributes["height"] = Height + if (Width >= 0) attributes["width"] = Width } } diff --git a/src/Elements/New-ColElement.psm1 b/src/Elements/New-ColElement.psm1 index ef3e0b9..9d51593 100644 --- a/src/Elements/New-ColElement.psm1 +++ b/src/Elements/New-ColElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `col` element. #> [Cmdlet(VerbsCommon.New, "HtmlColElement"), Alias("col"), OutputType(typeof(string))] -function New-HtmlColElementCommand(): NewElementCommand("col", isVoid: true) { +function New-HtmlColElement: NewElementCommand("col", isVoid: true) { <# .SYNOPSIS @@ -21,6 +21,6 @@ function New-HtmlColElementCommand(): NewElementCommand("col", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Span > 0) attributes["span"] = Span.ToString(CultureInfo.InvariantCulture); + if (Span > 0) attributes["span"] = Span } } diff --git a/src/Elements/New-ColGroupElement.psm1 b/src/Elements/New-ColGroupElement.psm1 index 5faeec5..a522bac 100644 --- a/src/Elements/New-ColGroupElement.psm1 +++ b/src/Elements/New-ColGroupElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `colgroup` element. #> [Cmdlet(VerbsCommon.New, "HtmlColgroupElement"), Alias("colgroup"), OutputType(typeof(string))] -function New-HtmlColgroupElementCommand(): NewElementCommand("colgroup", isVoid: false) { +function New-HtmlColgroupElement: NewElementCommand("colgroup", isVoid: false) { <# .SYNOPSIS @@ -21,6 +21,6 @@ function New-HtmlColgroupElementCommand(): NewElementCommand("colgroup", isVoid: /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Span > 0) attributes["span"] = Span.ToString(CultureInfo.InvariantCulture); + if (Span > 0) attributes["span"] = Span } } diff --git a/src/Elements/New-DataElement.psm1 b/src/Elements/New-DataElement.psm1 index 34266f7..cafd702 100644 --- a/src/Elements/New-DataElement.psm1 +++ b/src/Elements/New-DataElement.psm1 @@ -1,15 +1,17 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `data` element. #> [Cmdlet(VerbsCommon.New, "HtmlDataElement"), Alias("dataTag"), OutputType(typeof(string))] -function New-HtmlDataElementCommand(): NewElementCommand("data", isVoid: false) { +function New-HtmlDataElement: NewElementCommand("data", isVoid: false) { <# .SYNOPSIS The machine-readable translation of the content of the element. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required string Value <# diff --git a/src/Elements/New-DelElement.psm1 b/src/Elements/New-DelElement.psm1 index 913671f..a92b5d1 100644 --- a/src/Elements/New-DelElement.psm1 +++ b/src/Elements/New-DelElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `del` element. #> [Cmdlet(VerbsCommon.New, "HtmlDelElement"), Alias("delTag"), OutputType(typeof(string))] -function New-HtmlDelElementCommand(): NewElementCommand("del", isVoid: false) { +function New-HtmlDelElement: NewElementCommand("del", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-DetailsElement.psm1 b/src/Elements/New-DetailsElement.psm1 index 332dabc..45a0c5c 100644 --- a/src/Elements/New-DetailsElement.psm1 +++ b/src/Elements/New-DetailsElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `details` element. #> [Cmdlet(VerbsCommon.New, "HtmlDetailsElement"), Alias("details"), OutputType(typeof(string))] -function New-HtmlDetailsElementCommand(): NewElementCommand("details", isVoid: false) { +function New-HtmlDetailsElement: NewElementCommand("details", isVoid: false) { <# .SYNOPSIS @@ -26,7 +28,7 @@ function New-HtmlDetailsElementCommand(): NewElementCommand("details", isVoid: f /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; if (Open) attributes["open"] = true; } } diff --git a/src/Elements/New-DialogElement.psm1 b/src/Elements/New-DialogElement.psm1 index 1674796..1292122 100644 --- a/src/Elements/New-DialogElement.psm1 +++ b/src/Elements/New-DialogElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `dialog` element. #> [Cmdlet(VerbsCommon.New, "HtmlDialogElement"), Alias("dialog"), OutputType(typeof(string))] -function New-HtmlDialogElementCommand(): NewElementCommand("dialog", isVoid: false) { +function New-HtmlDialogElement: NewElementCommand("dialog", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-EmbedElement.psm1 b/src/Elements/New-EmbedElement.psm1 index 5b43493..26c4f0d 100644 --- a/src/Elements/New-EmbedElement.psm1 +++ b/src/Elements/New-EmbedElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `embed` element. #> [Cmdlet(VerbsCommon.New, "HtmlEmbedElement"), Alias("embed"), OutputType(typeof(string))] -function New-HtmlEmbedElementCommand(): NewElementCommand("embed", isVoid: true) { +function New-HtmlEmbedElement: NewElementCommand("embed", isVoid: true) { <# .SYNOPSIS @@ -18,14 +18,14 @@ function New-HtmlEmbedElementCommand(): NewElementCommand("embed", isVoid: true) .SYNOPSIS The URL of the resource being embedded. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required Uri Src <# .SYNOPSIS The media type to use, optionally including a `codecs` parameter. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required string Type <# @@ -44,7 +44,7 @@ function New-HtmlEmbedElementCommand(): NewElementCommand("embed", isVoid: true) base.RenderAttributes(attributes); attributes["src"] = Src.ToString(); attributes["type"] = Type; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + if (Height >= 0) attributes["height"] = Height + if (Width >= 0) attributes["width"] = Width } } diff --git a/src/Elements/New-FieldsetElement.psm1 b/src/Elements/New-FieldsetElement.psm1 index 23b2313..9e63677 100644 --- a/src/Elements/New-FieldsetElement.psm1 +++ b/src/Elements/New-FieldsetElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `fieldset` element. #> [Cmdlet(VerbsCommon.New, "HtmlFieldsetElement"), Alias("fieldset"), OutputType(typeof(string))] -function New-HtmlFieldsetElementCommand(): NewElementCommand("fieldset", isVoid: false) { +function New-HtmlFieldsetElement: NewElementCommand("fieldset", isVoid: false) { <# .SYNOPSIS @@ -34,7 +36,7 @@ function New-HtmlFieldsetElementCommand(): NewElementCommand("fieldset", isVoid: protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; } } diff --git a/src/Elements/New-FormElement.psm1 b/src/Elements/New-FormElement.psm1 index 038685f..32c7181 100644 --- a/src/Elements/New-FormElement.psm1 +++ b/src/Elements/New-FormElement.psm1 @@ -1,11 +1,12 @@ -using System.Net.Mime; +using namespace System.Net.Mime +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `form` element. #> [Cmdlet(VerbsCommon.New, "HtmlFormElement"), Alias("form"), OutputType(typeof(string))] -function New-HtmlFormElementCommand(): NewElementCommand("form", isVoid: false) { +function New-HtmlFormElement: NewElementCommand("form", isVoid: false) { <# .SYNOPSIS @@ -57,7 +58,7 @@ function New-HtmlFormElementCommand(): NewElementCommand("form", isVoid: false) The annotations and what kinds of links the form creates. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $Rel = []; + [string[]] $Rel = @(), <# .SYNOPSIS @@ -77,9 +78,9 @@ function New-HtmlFormElementCommand(): NewElementCommand("form", isVoid: false) if (AutoComplete is not null) attributes["autocomplete"] = AutoComplete; if (Enctype is not null) attributes["enctype"] = Enctype; if (Method is not null) attributes["method"] = Method; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; if (NoValidate) attributes["novalidate"] = true; if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); - if (!string.IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + if (-not [string]::IsNullOrWhiteSpace(Target)) attributes["target"] = Target; } } diff --git a/src/Elements/New-IframeElement.psm1 b/src/Elements/New-IframeElement.psm1 index 520dbe5..789496e 100644 --- a/src/Elements/New-IframeElement.psm1 +++ b/src/Elements/New-IframeElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `iframe` element. #> [Cmdlet(VerbsCommon.New, "HtmlIframeElement"), Alias("iframe"), OutputType(typeof(string))] -function New-HtmlIframeElementCommand(): NewElementCommand("iframe", isVoid: false) { +function New-HtmlIframeElement: NewElementCommand("iframe", isVoid: false) { <# .SYNOPSIS @@ -52,13 +52,13 @@ function New-HtmlIframeElementCommand(): NewElementCommand("iframe", isVoid: fal The restrictions applied to the content embedded in the frame. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $Sandbox = []; + [string[]] $Sandbox = @(), <# .SYNOPSIS The URL of the page to embed. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required Uri Src <# @@ -76,12 +76,12 @@ function New-HtmlIframeElementCommand(): NewElementCommand("iframe", isVoid: fal protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); attributes["src"] = Src.ToString(); - if (!string.IsNullOrWhiteSpace(Allow)) attributes["allow"] = Allow; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (-not [string]::IsNullOrWhiteSpace(Allow)) attributes["allow"] = Allow; + if (Height >= 0) attributes["height"] = Height if (Loading is not null) attributes["loading"] = Loading; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; if (ReferrerPolicy is not null) attributes["referrerpolicy"] = ReferrerPolicy; if (Sandbox.Length > 0) attributes["sandbox"] = string.Join(' ', Sandbox).Trim(); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + if (Width >= 0) attributes["width"] = Width } } diff --git a/src/Elements/New-ImgElement.psm1 b/src/Elements/New-ImgElement.psm1 index 80f390e..a39d81e 100644 --- a/src/Elements/New-ImgElement.psm1 +++ b/src/Elements/New-ImgElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `img` element. #> [Cmdlet(VerbsCommon.New, "HtmlImgElement"), Alias("img"), OutputType(typeof(string))] -function New-HtmlImgElementCommand(): NewElementCommand("img", isVoid: true) { +function New-HtmlImgElement: NewElementCommand("img", isVoid: true) { <# .SYNOPSIS @@ -41,13 +41,13 @@ function New-HtmlImgElementCommand(): NewElementCommand("img", isVoid: true) { The intended display sizes of the image. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $Sizes = []; + [string[]] $Sizes = @(), <# .SYNOPSIS The image URL. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required Uri Src <# @@ -55,7 +55,7 @@ function New-HtmlImgElementCommand(): NewElementCommand("img", isVoid: true) { The possible image sources for the user agent to use. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $SrcSet = []; + [string[]] $SrcSet = @(), <# .SYNOPSIS @@ -80,12 +80,12 @@ function New-HtmlImgElementCommand(): NewElementCommand("img", isVoid: true) { base.RenderAttributes(attributes); attributes["src"] = Src.ToString(); if (Alt is not null) attributes["alt"] = Alt; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (Height >= 0) attributes["height"] = Height if (IsMap) attributes["ismap"] = true; if (Loading is not null) attributes["loading"] = Loading; if (Sizes.Length > 0) attributes["sizes"] = string.Join(", ", Sizes); if (SrcSet.Length > 0) attributes["srcset"] = string.Join(", ", SrcSet); - if (!string.IsNullOrWhiteSpace(UseMap)) attributes["usemap"] = UseMap.StartsWith('#') ? UseMap : $"#{UseMap}"; - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + if (-not [string]::IsNullOrWhiteSpace(UseMap)) attributes["usemap"] = UseMap.StartsWith('#') ? UseMap : $"#{UseMap}"; + if (Width >= 0) attributes["width"] = Width } } diff --git a/src/Elements/New-InputElement.psm1 b/src/Elements/New-InputElement.psm1 index b589a1f..83348b4 100644 --- a/src/Elements/New-InputElement.psm1 +++ b/src/Elements/New-InputElement.psm1 @@ -1,13 +1,12 @@ -using System.Globalization; -using System.Net.Mime; -using System.Text.RegularExpressions; +using namespace System.Net.Mime +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `input` element. #> [Cmdlet(VerbsCommon.New, "HtmlInputElement"), Alias("input"), OutputType(typeof(string))] -function New-HtmlInputElementCommand(): NewElementCommand("input", isVoid: true) { +function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { <# .SYNOPSIS @@ -30,7 +29,7 @@ function New-HtmlInputElementCommand(): NewElementCommand("input", isVoid: true) A hint for a user agent's autocomplete feature. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $AutoComplete = []; + [string[]] $AutoComplete = @(), <# .SYNOPSIS @@ -267,37 +266,37 @@ function New-HtmlInputElementCommand(): NewElementCommand("input", isVoid: true) /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Accept)) attributes["accept"] = Accept; + if (-not [string]::IsNullOrWhiteSpace(Accept)) attributes["accept"] = Accept; if (Alt is not null) attributes["alt"] = Alt; if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); if (Capture is not null) attributes["capture"] = Capture; if (Checked) attributes["checked"] = true; - if (!string.IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; + if (-not [string]::IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; if (FormAction is not null) attributes["formaction"] = FormAction.ToString(); if (FormEnctype is not null) attributes["formenctype"] = FormEnctype; if (FormMethod is not null) attributes["formmethod"] = FormMethod; if (FormNoValidate) attributes["formnovalidate"] = true; - if (!string.IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(List)) attributes["list"] = List; - if (!string.IsNullOrWhiteSpace(Max)) attributes["max"] = Max; - if (MaxLength >= 0) attributes["maxlength"] = MaxLength.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Min)) attributes["min"] = Min; - if (MinLength >= 0) attributes["minlength"] = MinLength.ToString(CultureInfo.InvariantCulture); + if (-not [string]::IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; + if (Height >= 0) attributes["height"] = Height + if (-not [string]::IsNullOrWhiteSpace(List)) attributes["list"] = List; + if (-not [string]::IsNullOrWhiteSpace(Max)) attributes["max"] = Max; + if (MaxLength >= 0) attributes["maxlength"] = MaxLength + if (-not [string]::IsNullOrWhiteSpace(Min)) attributes["min"] = Min; + if (MinLength >= 0) attributes["minlength"] = MinLength if (Multiple) attributes["multiple"] = true; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; if (Pattern is not null) attributes["pattern"] = Pattern.ToString().Replace(@"\", @"\\"); - if (!string.IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; - if (!string.IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; + if (-not [string]::IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; + if (-not [string]::IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; if (PopoverTargetAction is not null) attributes["popovertargetaction"] = PopoverTargetAction; if (ReadOnly) attributes["readonly"] = true; if (Required) attributes["required"] = true; - if (Size > 0) attributes["size"] = Size.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Step)) attributes["step"] = Step; + if (Size > 0) attributes["size"] = Size + if (-not [string]::IsNullOrWhiteSpace(Step)) attributes["step"] = Step; if (Type is not null) attributes["type"] = Type; if (Value is not null) attributes["value"] = Value; - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + if (Width >= 0) attributes["width"] = Width } } diff --git a/src/Elements/New-InsElement.psm1 b/src/Elements/New-InsElement.psm1 index 398871d..5db1e0d 100644 --- a/src/Elements/New-InsElement.psm1 +++ b/src/Elements/New-InsElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `ins` element. #> [Cmdlet(VerbsCommon.New, "HtmlInsElement"), Alias("ins"), OutputType(typeof(string))] -function New-HtmlInsElementCommand(): NewElementCommand("ins", isVoid: false) { +function New-HtmlInsElement: NewElementCommand("ins", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-LabelElement.psm1 b/src/Elements/New-LabelElement.psm1 index c4bbb97..3870e8c 100644 --- a/src/Elements/New-LabelElement.psm1 +++ b/src/Elements/New-LabelElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `label` element. #> [Cmdlet(VerbsCommon.New, "HtmlLabelElement"), Alias("label"), OutputType(typeof(string))] -function New-HtmlLabelElementCommand(): NewElementCommand("label", isVoid: false) { +function New-HtmlLabelElement: NewElementCommand("label", isVoid: false) { <# .SYNOPSIS @@ -19,6 +21,6 @@ function New-HtmlLabelElementCommand(): NewElementCommand("label", isVoid: false /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(For)) attributes["for"] = For; + if (-not [string]::IsNullOrWhiteSpace(For)) attributes["for"] = For; } } diff --git a/src/Elements/New-LiElement.psm1 b/src/Elements/New-LiElement.psm1 index 0877765..41831d4 100644 --- a/src/Elements/New-LiElement.psm1 +++ b/src/Elements/New-LiElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `li` element. #> [Cmdlet(VerbsCommon.New, "HtmlLiElement"), Alias("li"), OutputType(typeof(string))] -function New-HtmlLiElementCommand(): NewElementCommand("li", isVoid: false) { +function New-HtmlLiElement: NewElementCommand("li", isVoid: false) { <# .SYNOPSIS @@ -21,6 +21,6 @@ function New-HtmlLiElementCommand(): NewElementCommand("li", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); + if (Value is not null) attributes["value"] = Value.Value } } diff --git a/src/Elements/New-LinkElement.psm1 b/src/Elements/New-LinkElement.psm1 index fc50660..070479a 100644 --- a/src/Elements/New-LinkElement.psm1 +++ b/src/Elements/New-LinkElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `link` element. #> [Cmdlet(VerbsCommon.New, "HtmlLinkElement"), Alias("link"), OutputType(typeof(string))] -function New-HtmlLinkElementCommand(): NewElementCommand("link", isVoid: true) { +function New-HtmlLinkElement: NewElementCommand("link", isVoid: true) { <# .SYNOPSIS @@ -24,7 +26,7 @@ function New-HtmlLinkElementCommand(): NewElementCommand("link", isVoid: true) { .SYNOPSIS The URL of the linked resource. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [uri] $Href <# @@ -45,7 +47,7 @@ function New-HtmlLinkElementCommand(): NewElementCommand("link", isVoid: true) { .SYNOPSIS The relationship of the linked resource to the current document. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required [string[]] $Rel <# @@ -53,7 +55,7 @@ function New-HtmlLinkElementCommand(): NewElementCommand("link", isVoid: true) { The sizes of the icons for visual media contained in the resource. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $Sizes = []; + [string[]] $Sizes = @(), <# .SYNOPSIS @@ -71,11 +73,11 @@ function New-HtmlLinkElementCommand(): NewElementCommand("link", isVoid: true) { base.RenderAttributes(attributes); attributes["rel"] = string.Join(' ', Rel).Trim(); attributes["href"] = Href.ToString(); - if (!string.IsNullOrWhiteSpace(As)) attributes["as"] = As; + if (-not [string]::IsNullOrWhiteSpace(As)) attributes["as"] = As; if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (!string.IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; - if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; + if (-not [string]::IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; + if (-not [string]::IsNullOrWhiteSpace(Media)) attributes["media"] = Media; if (Sizes.Length > 0) attributes["sizes"] = string.Join(' ', Sizes).Trim(); - if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + if (-not [string]::IsNullOrWhiteSpace(Type)) attributes["type"] = Type; } } diff --git a/src/Elements/New-MapElement.psm1 b/src/Elements/New-MapElement.psm1 index d9c608c..8a96585 100644 --- a/src/Elements/New-MapElement.psm1 +++ b/src/Elements/New-MapElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `map` element. #> [Cmdlet(VerbsCommon.New, "HtmlMapElement"), Alias("map"), OutputType(typeof(string))] -function New-HtmlMapElementCommand(): NewElementCommand("map", isVoid: false) { +function New-HtmlMapElement: NewElementCommand("map", isVoid: false) { <# .SYNOPSIS @@ -19,6 +21,6 @@ function New-HtmlMapElementCommand(): NewElementCommand("map", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; } } diff --git a/src/Elements/New-MetaElement.psm1 b/src/Elements/New-MetaElement.psm1 index 933c272..077a9e9 100644 --- a/src/Elements/New-MetaElement.psm1 +++ b/src/Elements/New-MetaElement.psm1 @@ -1,37 +1,39 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `meta` element. #> [Cmdlet(VerbsCommon.New, "HtmlMetaElement", DefaultParameterSetName = nameof(Name)), Alias("meta"), OutputType(typeof(string))] -function New-HtmlMetaElementCommand(): NewElementCommand("meta", isVoid: true) { +function New-HtmlMetaElement: NewElementCommand("meta", isVoid: true) { <# .SYNOPSIS A charset declaration, giving the character encoding in which the document is encoded. #> - [Parameter(Mandatory = true, ParameterSetName = nameof(Charset), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(Charset), ValueFromPipelineByPropertyName)] required string Charset <# .SYNOPSIS Contains the value for the `http-equiv` or `name attribute`, depending on which is used. #> - [Parameter(Mandatory = true, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName)] - [Parameter(Mandatory = true, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName)] override [object] $Content { get => base.Content; set => base.Content = value; } <# .SYNOPSIS A pragma directive to simulate directives that could otherwise be given by an HTTP header. #> - [Parameter(Mandatory = true, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName)] required string HttpEquiv <# .SYNOPSIS Document-level metadata that applies to the whole page. #> - [Parameter(Mandatory = true, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName)] required string Name <# diff --git a/src/Elements/New-MeterElement.psm1 b/src/Elements/New-MeterElement.psm1 index b644020..2cb21dd 100644 --- a/src/Elements/New-MeterElement.psm1 +++ b/src/Elements/New-MeterElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `meter` element. #> [Cmdlet(VerbsCommon.New, "HtmlMeterElement"), Alias("meter"), OutputType(typeof(string))] -function New-HtmlMeterElementCommand(): NewElementCommand("meter", isVoid: false) { +function New-HtmlMeterElement: NewElementCommand("meter", isVoid: false) { <# .SYNOPSIS @@ -56,11 +56,11 @@ function New-HtmlMeterElementCommand(): NewElementCommand("meter", isVoid: false /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (High is not null) attributes["high"] = High.Value.ToString(CultureInfo.InvariantCulture); - if (Low is not null) attributes["low"] = Low.Value.ToString(CultureInfo.InvariantCulture); - if (Max is not null) attributes["max"] = Max.Value.ToString(CultureInfo.InvariantCulture); - if (Min is not null) attributes["min"] = Min.Value.ToString(CultureInfo.InvariantCulture); - if (Optimum is not null) attributes["optimum"] = Optimum.Value.ToString(CultureInfo.InvariantCulture); - if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); + if (High is not null) attributes["high"] = High.Value + if (Low is not null) attributes["low"] = Low.Value + if (Max is not null) attributes["max"] = Max.Value + if (Min is not null) attributes["min"] = Min.Value + if (Optimum is not null) attributes["optimum"] = Optimum.Value + if (Value is not null) attributes["value"] = Value.Value } } diff --git a/src/Elements/New-ObjectElement.psm1 b/src/Elements/New-ObjectElement.psm1 index 6f234dd..2f2af12 100644 --- a/src/Elements/New-ObjectElement.psm1 +++ b/src/Elements/New-ObjectElement.psm1 @@ -1,17 +1,17 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `object` element. #> [Cmdlet(VerbsCommon.New, "HtmlObjectElement"), Alias("object"), OutputType(typeof(string))] -function New-HtmlObjectElementCommand(): NewElementCommand("object", isVoid: false) { +function New-HtmlObjectElement: NewElementCommand("object", isVoid: false) { <# .SYNOPSIS The URL of the resource being embedded. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required Uri Data <# @@ -39,7 +39,7 @@ function New-HtmlObjectElementCommand(): NewElementCommand("object", isVoid: fal .SYNOPSIS The media type to use, optionally including a `codecs` parameter. #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required string Type <# @@ -58,9 +58,9 @@ function New-HtmlObjectElementCommand(): NewElementCommand("object", isVoid: fal base.RenderAttributes(attributes); attributes["data"] = Data.ToString(); attributes["type"] = Type; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (Height >= 0) attributes["height"] = Height + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (Width >= 0) attributes["width"] = Width } } diff --git a/src/Elements/New-OlElement.psm1 b/src/Elements/New-OlElement.psm1 index 7f3a6dd..88f529a 100644 --- a/src/Elements/New-OlElement.psm1 +++ b/src/Elements/New-OlElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `ol` element. #> [Cmdlet(VerbsCommon.New, "HtmlOlElement"), Alias("ol"), OutputType(typeof(string))] -function New-HtmlOlElementCommand(): NewElementCommand("ol", isVoid: false) { +function New-HtmlOlElement: NewElementCommand("ol", isVoid: false) { <# .SYNOPSIS @@ -37,7 +37,7 @@ function New-HtmlOlElementCommand(): NewElementCommand("ol", isVoid: false) { protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); if (Reversed) attributes["reversed"] = true; - if (Start is not null) attributes["start"] = Start.Value.ToString(CultureInfo.InvariantCulture); + if (Start is not null) attributes["start"] = Start.Value if (Type is not null) attributes["type"] = Type; } } diff --git a/src/Elements/New-OptgroupElement.psm1 b/src/Elements/New-OptgroupElement.psm1 index 6ae806b..682dd0b 100644 --- a/src/Elements/New-OptgroupElement.psm1 +++ b/src/Elements/New-OptgroupElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `optgroup` element. #> [Cmdlet(VerbsCommon.New, "HtmlOptgroupElement"), Alias("optgroup"), OutputType(typeof(string))] -function New-HtmlOptgroupElementCommand(): NewElementCommand("optgroup", isVoid: false) { +function New-HtmlOptgroupElement: NewElementCommand("optgroup", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-OptionElement.psm1 b/src/Elements/New-OptionElement.psm1 index e2feba2..a44db72 100644 --- a/src/Elements/New-OptionElement.psm1 +++ b/src/Elements/New-OptionElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `option` element. #> [Cmdlet(VerbsCommon.New, "HtmlOptionElement"), Alias("option"), OutputType(typeof(string))] -function New-HtmlOptionElementCommand(): NewElementCommand("option", isVoid: false) { +function New-HtmlOptionElement: NewElementCommand("option", isVoid: false) { <# .SYNOPSIS @@ -41,7 +43,7 @@ function New-HtmlOptionElementCommand(): NewElementCommand("option", isVoid: fal protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Label)) attributes["label"] = Label; + if (-not [string]::IsNullOrWhiteSpace(Label)) attributes["label"] = Label; if (Selected) attributes["selected"] = true; if (Value is not null) attributes["value"] = Value; } diff --git a/src/Elements/New-OutputElement.psm1 b/src/Elements/New-OutputElement.psm1 index b1ffc2c..691be9e 100644 --- a/src/Elements/New-OutputElement.psm1 +++ b/src/Elements/New-OutputElement.psm1 @@ -1,16 +1,18 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `output` element. #> [Cmdlet(VerbsCommon.New, "HtmlOutputElement"), Alias("output"), OutputType(typeof(string))] -function New-HtmlOutputElementCommand(): NewElementCommand("output", isVoid: false) { +function New-HtmlOutputElement: NewElementCommand("output", isVoid: false) { <# .SYNOPSIS A list of other elements' identifiers, indicating that those elements contributed input values to the calculation. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $For = []; + [string[]] $For = @(), <# .SYNOPSIS @@ -34,7 +36,7 @@ function New-HtmlOutputElementCommand(): NewElementCommand("output", isVoid: fal protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); if (For.Length > 0) attributes["for"] = string.Join(' ', For).Trim(); - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; } } diff --git a/src/Elements/New-ProgressElement.psm1 b/src/Elements/New-ProgressElement.psm1 index 62542d6..7094983 100644 --- a/src/Elements/New-ProgressElement.psm1 +++ b/src/Elements/New-ProgressElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `progress` element. #> [Cmdlet(VerbsCommon.New, "HtmlProgressElement"), Alias("progress"), OutputType(typeof(string))] -function New-HtmlProgressElementCommand(): NewElementCommand("progress", isVoid: false) { +function New-HtmlProgressElement: NewElementCommand("progress", isVoid: false) { <# .SYNOPSIS @@ -28,7 +28,7 @@ function New-HtmlProgressElementCommand(): NewElementCommand("progress", isVoid: /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Max is not null) attributes["max"] = Max.Value.ToString(CultureInfo.InvariantCulture); - if (Value is not null) attributes["value"] = Value.Value.ToString(CultureInfo.InvariantCulture); + if (Max is not null) attributes["max"] = Max.Value + if (Value is not null) attributes["value"] = Value.Value } } diff --git a/src/Elements/New-QElement.psm1 b/src/Elements/New-QElement.psm1 index 3020373..ad2218b 100644 --- a/src/Elements/New-QElement.psm1 +++ b/src/Elements/New-QElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `q` element. #> [Cmdlet(VerbsCommon.New, "HtmlQElement"), Alias("q"), OutputType(typeof(string))] -function New-HtmlQElementCommand(): NewElementCommand("q", isVoid: false) { +function New-HtmlQElement: NewElementCommand("q", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-ScriptElement.psm1 b/src/Elements/New-ScriptElement.psm1 index aa74ee4..6a23880 100644 --- a/src/Elements/New-ScriptElement.psm1 +++ b/src/Elements/New-ScriptElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `script` element. #> [Cmdlet(VerbsCommon.New, "HtmlScriptElement"), Alias("script"), OutputType(typeof(string))] -function New-HtmlScriptElementCommand(): NewElementCommand("script", isVoid: false) { +function New-HtmlScriptElement: NewElementCommand("script", isVoid: false) { <# .SYNOPSIS @@ -59,7 +61,7 @@ function New-HtmlScriptElementCommand(): NewElementCommand("script", isVoid: fal if (Async) attributes["async"] = true; if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; if (Defer) attributes["defer"] = true; - if (!string.IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; - if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + if (-not [string]::IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; + if (-not [string]::IsNullOrWhiteSpace(Type)) attributes["type"] = Type; } } diff --git a/src/Elements/New-SelectElement.psm1 b/src/Elements/New-SelectElement.psm1 index 0e2f7b3..8e70254 100644 --- a/src/Elements/New-SelectElement.psm1 +++ b/src/Elements/New-SelectElement.psm1 @@ -1,18 +1,18 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `select` element. #> [Cmdlet(VerbsCommon.New, "HtmlSelectElement"), Alias("selectTag"), OutputType(typeof(string))] -function New-HtmlSelectElementCommand(): NewElementCommand("select", isVoid: false) { +function New-HtmlSelectElement: NewElementCommand("select", isVoid: false) { <# .SYNOPSIS A hint for a user agent's autocomplete feature. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $AutoComplete = []; + [string[]] $AutoComplete = @(), <# .SYNOPSIS @@ -65,10 +65,10 @@ function New-HtmlSelectElementCommand(): NewElementCommand("select", isVoid: fal base.RenderAttributes(attributes); if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; if (Multiple) attributes["multiple"] = true; - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; if (Required) attributes["required"] = true; - if (Size >= 0) attributes["size"] = Size.ToString(CultureInfo.InvariantCulture); + if (Size >= 0) attributes["size"] = Size } } diff --git a/src/Elements/New-SlotElement.psm1 b/src/Elements/New-SlotElement.psm1 index ad9134f..afa97dd 100644 --- a/src/Elements/New-SlotElement.psm1 +++ b/src/Elements/New-SlotElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `slot` element. #> [Cmdlet(VerbsCommon.New, "HtmlSlotElement"), Alias("slot"), OutputType(typeof(string))] -function New-HtmlSlotElementCommand(): NewElementCommand("slot", isVoid: false) { +function New-HtmlSlotElement: NewElementCommand("slot", isVoid: false) { <# .SYNOPSIS @@ -19,6 +21,6 @@ function New-HtmlSlotElementCommand(): NewElementCommand("slot", isVoid: false) /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; } } diff --git a/src/Elements/New-SourceElement.psm1 b/src/Elements/New-SourceElement.psm1 index 756d33f..ed97cf6 100644 --- a/src/Elements/New-SourceElement.psm1 +++ b/src/Elements/New-SourceElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `source` element. #> [Cmdlet(VerbsCommon.New, "HtmlSourceElement", DefaultParameterSetName = nameof(Src)), Alias("source"), OutputType(typeof(string))] -function New-HtmlSourceElementCommand(): NewElementCommand("source", isVoid: true) { +function New-HtmlSourceElement: NewElementCommand("source", isVoid: true) { <# .SYNOPSIS @@ -26,21 +26,21 @@ function New-HtmlSourceElementCommand(): NewElementCommand("source", isVoid: tru A list of source sizes that describe the final rendered width of the image. #> [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] - [string[]] $Sizes = []; + [string[]] $Sizes = @(), <# .SYNOPSIS The URL of the media resource #> - [Parameter(Mandatory = true, ParameterSetName = nameof(Src), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(Src), ValueFromPipelineByPropertyName)] required Uri Src <# .SYNOPSIS A list of one or more image URLs and their descriptors. #> - [Parameter(Mandatory = true, ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] - [string[]] $SrcSet = []; + [Parameter(Mandatory, ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] + [string[]] $SrcSet = @(), <# .SYNOPSIS @@ -63,7 +63,7 @@ function New-HtmlSourceElementCommand(): NewElementCommand("source", isVoid: tru /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + if (-not [string]::IsNullOrWhiteSpace(Type)) attributes["type"] = Type; switch (ParameterSetName) { case nameof(Src): @@ -72,10 +72,10 @@ function New-HtmlSourceElementCommand(): NewElementCommand("source", isVoid: tru case nameof(SrcSet): attributes["srcset"] = string.Join(", ", SrcSet); - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; + if (Height >= 0) attributes["height"] = Height + if (-not [string]::IsNullOrWhiteSpace(Media)) attributes["media"] = Media; if (Sizes.Length > 0) attributes["sizes"] = string.Join(", ", Sizes); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + if (Width >= 0) attributes["width"] = Width break; } } diff --git a/src/Elements/New-StyleElement.psm1 b/src/Elements/New-StyleElement.psm1 index da1a8e2..85b36ae 100644 --- a/src/Elements/New-StyleElement.psm1 +++ b/src/Elements/New-StyleElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `style` element. #> [Cmdlet(VerbsCommon.New, "HtmlStyleElement"), Alias("style"), OutputType(typeof(string))] -function New-HtmlStyleElementCommand(): NewElementCommand("style", isVoid: false) { +function New-HtmlStyleElement: NewElementCommand("style", isVoid: false) { <# .SYNOPSIS @@ -19,6 +21,6 @@ function New-HtmlStyleElementCommand(): NewElementCommand("style", isVoid: false /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Media)) attributes["media"] = Media; + if (-not [string]::IsNullOrWhiteSpace(Media)) attributes["media"] = Media; } } diff --git a/src/Elements/New-TdElement.psm1 b/src/Elements/New-TdElement.psm1 index e3e4e6f..c034589 100644 --- a/src/Elements/New-TdElement.psm1 +++ b/src/Elements/New-TdElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `th` element. #> [Cmdlet(VerbsCommon.New, "HtmlTdElement"), Alias("td"), OutputType(typeof(string))] -function New-HtmlTdElementCommand(): NewElementCommand("td", isVoid: false) { +function New-HtmlTdElement: NewElementCommand("td", isVoid: false) { <# .SYNOPSIS @@ -19,7 +19,7 @@ function New-HtmlTdElementCommand(): NewElementCommand("td", isVoid: false) { A list of strings corresponding to the `id` attributes of the `th` elements that provide the headers for this header cell. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $Headers = []; + [string[]] $Headers = @(), <# .SYNOPSIS @@ -35,8 +35,8 @@ function New-HtmlTdElementCommand(): NewElementCommand("td", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (ColSpan >= 0) attributes["colspan"] = ColSpan.ToString(CultureInfo.InvariantCulture); + if (ColSpan >= 0) attributes["colspan"] = ColSpan if (Headers.Length > 0) attributes["headers"] = string.Join(' ', Headers).Trim(); - if (RowSpan >= 0) attributes["rowspan"] = RowSpan.ToString(CultureInfo.InvariantCulture); + if (RowSpan >= 0) attributes["rowspan"] = RowSpan } } diff --git a/src/Elements/New-TemplateElement.psm1 b/src/Elements/New-TemplateElement.psm1 index 0e69db7..cb1389a 100644 --- a/src/Elements/New-TemplateElement.psm1 +++ b/src/Elements/New-TemplateElement.psm1 @@ -1,9 +1,11 @@ +using module ../New-Element.psm1 + <# .SYNOPSIS Creates a new `template` element. #> [Cmdlet(VerbsCommon.New, "HtmlTemplateElement"), Alias("template"), OutputType(typeof(string))] -function New-HtmlTemplateElementCommand(): NewElementCommand("template", isVoid: false) { +function New-HtmlTemplateElement: NewElementCommand("template", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-TextareaElement.psm1 b/src/Elements/New-TextareaElement.psm1 index 7dd5684..d9b7d7d 100644 --- a/src/Elements/New-TextareaElement.psm1 +++ b/src/Elements/New-TextareaElement.psm1 @@ -1,18 +1,18 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `textarea` element. #> [Cmdlet(VerbsCommon.New, "HtmlTextareaElement"), Alias("textarea"), OutputType(typeof(string))] -function New-HtmlTextareaElementCommand(): NewElementCommand("textarea", isVoid: false) { +function New-HtmlTextareaElement: NewElementCommand("textarea", isVoid: false) { <# .SYNOPSIS A hint for a user agent's autocomplete feature. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $AutoComplete = []; + [string[]] $AutoComplete = @(), <# .SYNOPSIS @@ -116,17 +116,17 @@ function New-HtmlTextareaElementCommand(): NewElementCommand("textarea", isVoid: base.RenderAttributes(attributes); if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); if (AutoCorrect is not null) attributes["autocorrect"] = AutoCorrect; - if (Cols > 0) attributes["cols"] = Cols.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; + if (Cols > 0) attributes["cols"] = Cols + if (-not [string]::IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; if (Disabled) attributes["disabled"] = true; - if (!string.IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (MaxLength >= 0) attributes["maxlength"] = MaxLength.ToString(CultureInfo.InvariantCulture); - if (MinLength >= 0) attributes["minlength"] = MinLength.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (!string.IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; + if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; + if (MaxLength >= 0) attributes["maxlength"] = MaxLength + if (MinLength >= 0) attributes["minlength"] = MinLength + if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (-not [string]::IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; if (ReadOnly) attributes["readonly"] = true; if (Required) attributes["required"] = true; - if (Rows > 0) attributes["rows"] = Rows.ToString(CultureInfo.InvariantCulture); + if (Rows > 0) attributes["rows"] = Rows if (Wrap is not null) attributes["wrap"] = Wrap; } } diff --git a/src/Elements/New-ThElement.psm1 b/src/Elements/New-ThElement.psm1 index dda87f9..2e4aeb9 100644 --- a/src/Elements/New-ThElement.psm1 +++ b/src/Elements/New-ThElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `th` element. #> [Cmdlet(VerbsCommon.New, "HtmlThElement"), Alias("th"), OutputType(typeof(string))] -function New-HtmlThElementCommand(): NewElementCommand("th", isVoid: false) { +function New-HtmlThElement: NewElementCommand("th", isVoid: false) { <# .SYNOPSIS @@ -26,7 +26,7 @@ function New-HtmlThElementCommand(): NewElementCommand("th", isVoid: false) { A list of strings corresponding to the `id` attributes of the `th` elements that provide the headers for this header cell. #> [Parameter(ValueFromPipelineByPropertyName)] - [string[]] $Headers = []; + [string[]] $Headers = @(), <# .SYNOPSIS @@ -50,10 +50,10 @@ function New-HtmlThElementCommand(): NewElementCommand("th", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (!string.IsNullOrWhiteSpace(Abbr)) attributes["abbr"] = Abbr; - if (ColSpan >= 0) attributes["colspan"] = ColSpan.ToString(CultureInfo.InvariantCulture); + if (-not [string]::IsNullOrWhiteSpace(Abbr)) attributes["abbr"] = Abbr; + if (ColSpan >= 0) attributes["colspan"] = ColSpan if (Headers.Length > 0) attributes["headers"] = string.Join(' ', Headers).Trim(); - if (RowSpan >= 0) attributes["rowspan"] = RowSpan.ToString(CultureInfo.InvariantCulture); + if (RowSpan >= 0) attributes["rowspan"] = RowSpan if (Scope is not null) attributes["scope"] = Scope; } } diff --git a/src/Elements/New-TimeElement.psm1 b/src/Elements/New-TimeElement.psm1 index 2d7649c..8dd07e9 100644 --- a/src/Elements/New-TimeElement.psm1 +++ b/src/Elements/New-TimeElement.psm1 @@ -1,11 +1,12 @@ -using System.Xml; +using namespace System.Xml +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `time` element. #> [Cmdlet(VerbsCommon.New, "HtmlTimeElement"), Alias("time"), OutputType(typeof(string))] -function New-HtmlTimeElementCommand(): NewElementCommand("time", isVoid: false) { +function New-HtmlTimeElement: NewElementCommand("time", isVoid: false) { <# .SYNOPSIS diff --git a/src/Elements/New-TrackElement.psm1 b/src/Elements/New-TrackElement.psm1 index 52943c2..5f2745e 100644 --- a/src/Elements/New-TrackElement.psm1 +++ b/src/Elements/New-TrackElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `track` element. #> [Cmdlet(VerbsCommon.New, "HtmlTrackElement"), Alias("track"), OutputType(typeof(string))] -function New-HtmlTrackElementCommand(): NewElementCommand("track", isVoid: true) { +function New-HtmlTrackElement: NewElementCommand("track", isVoid: true) { <# .SYNOPSIS @@ -33,7 +33,7 @@ function New-HtmlTrackElementCommand(): NewElementCommand("track", isVoid: true) .SYNOPSIS The address of the track (`.vtt` file). #> - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] required Uri Src <# @@ -53,7 +53,7 @@ function New-HtmlTrackElementCommand(): NewElementCommand("track", isVoid: true) attributes["src"] = Src.ToString(); if (Default) attributes["default"] = true; if (Kind is not null) attributes["kind"] = Kind; - if (!string.IsNullOrWhiteSpace(Label)) attributes["label"] = Label; + if (-not [string]::IsNullOrWhiteSpace(Label)) attributes["label"] = Label; if (SrcLang is not null) attributes["srclang"] = SrcLang.Name; } } diff --git a/src/Elements/New-VideoElement.psm1 b/src/Elements/New-VideoElement.psm1 index c14a25b..c51674f 100644 --- a/src/Elements/New-VideoElement.psm1 +++ b/src/Elements/New-VideoElement.psm1 @@ -1,11 +1,11 @@ -using System.Globalization; +using module ../New-Element.psm1 <# .SYNOPSIS Creates a new `video` element. #> [Cmdlet(VerbsCommon.New, "HtmlVideoElement"), Alias("video"), OutputType(typeof(string))] -function New-HtmlVideoElementCommand(): NewElementCommand("video", isVoid: false) { +function New-HtmlVideoElement: NewElementCommand("video", isVoid: false) { <# .SYNOPSIS @@ -112,13 +112,13 @@ function New-HtmlVideoElementCommand(): NewElementCommand("video", isVoid: false if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; if (DisablePictureInPicture) attributes["disablepictureinpicture"] = true; if (DisableRemotePlayback) attributes["disableremoteplayback"] = true; - if (Height >= 0) attributes["height"] = Height.ToString(CultureInfo.InvariantCulture); + if (Height >= 0) attributes["height"] = Height if (Loop) attributes["loop"] = true; if (Muted) attributes["muted"] = true; if (PlaysInline) attributes["playsinline"] = true; if (Poster is not null) attributes["poster"] = Poster.ToString(); if (Preload is not null) attributes["preload"] = Preload; if (Src is not null) attributes["src"] = Src.ToString(); - if (Width >= 0) attributes["width"] = Width.ToString(CultureInfo.InvariantCulture); + if (Width >= 0) attributes["width"] = Width } } From 1717892a7dc0ace94e496f9ef20c7eeccdeb4be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 15:08:16 +0200 Subject: [PATCH 16/23] Update the cmdlet template --- Html.psd1 | 2 +- share/Cmdlet.Template.cs | 11 +++++------ share/Cmdlet.Template.psm1 | 29 +++++++++++++++++++++++++++ tool/Build.ps1 | 40 ++++++++++++++++---------------------- 4 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 share/Cmdlet.Template.psm1 diff --git a/Html.psd1 b/Html.psd1 index 63dabc1..ec86634 100644 --- a/Html.psd1 +++ b/Html.psd1 @@ -1,5 +1,5 @@ @{ - # DefaultCommandPrefix = "Lcov" + # DefaultCommandPrefix = "Html" ModuleVersion = "2.0.0" PowerShellVersion = "7.6" diff --git a/share/Cmdlet.Template.cs b/share/Cmdlet.Template.cs index 494f5c7..8bdccb1 100644 --- a/share/Cmdlet.Template.cs +++ b/share/Cmdlet.Template.cs @@ -1,7 +1,6 @@ -namespace Belin.Html.Elements; - -/// -/// Creates a new {Tag} element. -/// +<# +.SYNOPSIS + Creates a new `{Tag}` element. +#> [Cmdlet(VerbsCommon.New, "Html{CapitalizedTag}Element"), Alias("{Alias}"), OutputType(typeof(string))] -public class New{CapitalizedTag}ElementCommand(): NewElementCommand("{Tag}", isVoid: {IsVoid}) {} +function New-Html{CapitalizedTag}Element: NewElementCommand("{Tag}", isVoid: {IsVoid}) {} diff --git a/share/Cmdlet.Template.psm1 b/share/Cmdlet.Template.psm1 new file mode 100644 index 0000000..b2d9fad --- /dev/null +++ b/share/Cmdlet.Template.psm1 @@ -0,0 +1,29 @@ +<# +.SYNOPSIS + Creates a new `{Tag}` element. +.INPUTS + The inner HTML of the `{Tag}` element. +.OUTPUTS + The newly created `{Tag}` element. +#> +function New-Html{CapitalizedTag}Element { + [Alias("{Alias}")] + [CmdletBinding()] + [OutputType([string])] + param ( + # The inner HTML of the element. + [Parameter(Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [object] $Content, + + # The custom attributes to render. + [Parameter(ValueFromPipelineByPropertyName)] + [hashtable] $Attributes = @{} + ) + + process { + # TODO handle void elements !!! they don't have content ! + $attributesToRender = $Attributes.Clone() + $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $PSBoundParameters.Remove($_) | Out-Null } + New-HtmlElement -TagName {Tag} -Attributes $attributesToRender -Content $Content -Void:{IsVoid} @PSBoundParameters + } +} diff --git a/tool/Build.ps1 b/tool/Build.ps1 index 8ad44c6..0229f53 100644 --- a/tool/Build.ps1 +++ b/tool/Build.ps1 @@ -2,31 +2,25 @@ using namespace System.Collections.Generic "Deploying the assets..." $cmdlets = [pscustomobject]@{ - Aliases = [List[string]]::new() - Functions = [List[string]]::new() - Modules = [List[string]]::new() + Aliases = [List[string]]::new([string[]] @( + "doctype" # New-HtmlDocumentType + # "layout" # Use-HtmlLayout + # "tag" # New-HtmlCustomElement + )) + Functions = [List[string]]::new([string[]] @( + # "New-HtmlCustomElement" + "New-HtmlDocumentType" + # "Use-HtmlLayout" + # "Write-HtmlView" + )) + Modules = [List[string]]::new([string[]] @( + # "src/New-CustomElement.psm1" + "src/New-DocumentType.psm1" + # "src/Use-Layout.psm1" + # "src/Write-View.psm1" + )) } -$cmdlets.Aliases = [List[string]]::new([string[]] @( - # "doctype" - # "layout" - # "tag" -)) - -$cmdlets.Functions = [List[string]]::new([string[]] @( - # "New-HtmlCustomElement" - # "New-HtmlDocumentType" - # "Use-HtmlLayout" - # "Write-HtmlView" -)) - -$cmdlets.Modules = [List[string]]::new([string[]] @( - # "src/New-CustomElement.psm1" - # "src/New-DocumentType.psm1" - # "src/Use-Layout.psm1" - # "src/Write-View.psm1" -)) - # Generate the cmdlets. New-Item src/Generated -Force -ItemType Directory | Out-Null $cmdletTemplate = Get-Content share/Cmdlet.Template.psm1 -Raw From fe84f179046b4c48fb5f020030e3c84a9a9f7895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 15:12:13 +0200 Subject: [PATCH 17/23] Drop support of the `ValueFromPipelineByPropertyName` flag --- src/Elements/New-AElement.psm1 | 16 +++++----- src/Elements/New-AreaElement.psm1 | 10 ++---- src/Elements/New-AudioElement.psm1 | 8 ----- src/Elements/New-BaseElement.psm1 | 3 +- src/Elements/New-BlockquoteElement.psm1 | 1 - src/Elements/New-ButtonElement.psm1 | 14 --------- src/Elements/New-CanvasElement.psm1 | 4 +-- src/Elements/New-ColElement.psm1 | 2 +- src/Elements/New-ColGroupElement.psm1 | 2 +- src/Elements/New-DataElement.psm1 | 2 +- src/Elements/New-DelElement.psm1 | 2 -- src/Elements/New-DetailsElement.psm1 | 2 -- src/Elements/New-DialogElement.psm1 | 2 -- src/Elements/New-EmbedElement.psm1 | 8 ++--- src/Elements/New-FieldsetElement.psm1 | 3 -- src/Elements/New-FormElement.psm1 | 8 ----- src/Elements/New-IframeElement.psm1 | 11 ++----- src/Elements/New-ImgElement.psm1 | 11 ++----- src/Elements/New-InputElement.psm1 | 41 +++++-------------------- src/Elements/New-InsElement.psm1 | 2 -- src/Elements/New-LabelElement.psm1 | 1 - src/Elements/New-LiElement.psm1 | 1 - src/Elements/New-LinkElement.psm1 | 10 ++---- src/Elements/New-MapElement.psm1 | 1 - src/Elements/New-MetaElement.psm1 | 10 +++--- src/Elements/New-MeterElement.psm1 | 6 ---- src/Elements/New-ObjectElement.psm1 | 10 +++--- src/Elements/New-OlElement.psm1 | 3 -- src/Elements/New-OptgroupElement.psm1 | 2 -- src/Elements/New-OptionElement.psm1 | 4 --- src/Elements/New-OutputElement.psm1 | 3 -- src/Elements/New-ProgressElement.psm1 | 4 +-- src/Elements/New-QElement.psm1 | 1 - src/Elements/New-ScriptElement.psm1 | 6 ---- src/Elements/New-SelectElement.psm1 | 8 +---- src/Elements/New-SlotElement.psm1 | 1 - src/Elements/New-SourceElement.psm1 | 13 ++++---- src/Elements/New-StyleElement.psm1 | 1 - src/Elements/New-TdElement.psm1 | 5 ++- src/Elements/New-TemplateElement.psm1 | 4 --- src/Elements/New-TextareaElement.psm1 | 18 +++-------- src/Elements/New-ThElement.psm1 | 7 ++--- src/Elements/New-TimeElement.psm1 | 1 - src/Elements/New-TrackElement.psm1 | 6 +--- src/Elements/New-VideoElement.psm1 | 15 ++------- 45 files changed, 64 insertions(+), 229 deletions(-) diff --git a/src/Elements/New-AElement.psm1 b/src/Elements/New-AElement.psm1 index 5aa751c..d1299da 100644 --- a/src/Elements/New-AElement.psm1 +++ b/src/Elements/New-AElement.psm1 @@ -13,28 +13,27 @@ function New-HtmlAElement { [CmdletBinding()] [OutputType([string])] param ( + # The inner HTML of the element. + [Parameter(Position = 0, ValueFromPipeline)] + [object] $Content, + # The custom attributes to render. - [Parameter(ValueFromPipelineByPropertyName)] [hashtable] $Attributes = @{}, # The suggested filename when the browser treats the linked URL as a download. - [Parameter(ValueFromPipelineByPropertyName)] [string] $Download, # The URL that the hyperlink points to. - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] [uri] $Href, # A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. - [Parameter(ValueFromPipelineByPropertyName)] [uri[]] $Ping = @(), # The relationship of the linked URL. - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $Rel = @(), # The browsing context to show the results of navigation. - [Parameter(ValueFromPipelineByPropertyName)] [string] $Target ) @@ -46,8 +45,7 @@ function New-HtmlAElement { if ($Rel) { $attributesToRender.rel = ($Rel -join " ").Trim() } if ($Target) { $attributesToRender.target = $Target } - $parameters = $PSBoundParameters.Clone() - $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $parameters.Remove($_) } - New-Element -Attributes $attributesToRender @parameters + $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $PSBoundParameters.Remove($_) | Out-Null } + New-HtmlElement -TagName a -Attributes $attributesToRender -Content $Content @PSBoundParameters } } diff --git a/src/Elements/New-AreaElement.psm1 b/src/Elements/New-AreaElement.psm1 index d8f2d76..74cfd1e 100644 --- a/src/Elements/New-AreaElement.psm1 +++ b/src/Elements/New-AreaElement.psm1 @@ -11,49 +11,44 @@ function New-HtmlAreaElement: NewElementCommand("area", isVoid: true) { .SYNOPSIS A text to display on browsers that do not display images. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Alt <# .SYNOPSIS The browsing context to show the results of navigation. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateCount(3, int.MaxValue)] + [ValidateCount(3, int.MaxValue)] double[]? Coords <# .SYNOPSIS The suggested filename when the browser treats the linked URL as a download. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Download <# .SYNOPSIS The hyperlink target for the area. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] [uri] $Href <# .SYNOPSIS A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. #> - [Parameter(ValueFromPipelineByPropertyName)] [uri[]] $Ping = @(), <# .SYNOPSIS The relationship of the linked URL. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $Rel = @(), <# .SYNOPSIS The browsing context to show the results of navigation. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("circle", "default", "poly", "rect")] [string] $Shape @@ -61,7 +56,6 @@ function New-HtmlAreaElement: NewElementCommand("area", isVoid: true) { .SYNOPSIS The browsing context to show the results of navigation. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Target <# diff --git a/src/Elements/New-AudioElement.psm1 b/src/Elements/New-AudioElement.psm1 index 3778ee4..9f1c7c7 100644 --- a/src/Elements/New-AudioElement.psm1 +++ b/src/Elements/New-AudioElement.psm1 @@ -11,21 +11,18 @@ function New-HtmlAudioElement: NewElementCommand("audio", isVoid: false) { .SYNOPSIS Value indicating whether playback should start automatically as soon as the audio signal allows. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $AutoPlay <# .SYNOPSIS Value indicating whether to offer controls to allow the user to control audio playback. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Controls <# .SYNOPSIS Value indicating whether CORS must be used when fetching the resource. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("anonymous", "use-credentials")] [string] $CrossOrigin @@ -33,28 +30,24 @@ function New-HtmlAudioElement: NewElementCommand("audio", isVoid: false) { .SYNOPSIS Value indicating whether to disable the capability of remote playback in devices that are attached using wired and wireless technologies. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $DisableRemotePlayback <# .SYNOPSIS Value indicating whether the audio player will automatically seek back to the start upon reaching the end of the audio. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Loop <# .SYNOPSIS Value indicating whether the audio will be initially silenced. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Muted <# .SYNOPSIS Value providing a hint to the browser about what the author thinks will lead to the best user experience. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("auto", "none", "metadata")] [string] $Preload @@ -62,7 +55,6 @@ function New-HtmlAudioElement: NewElementCommand("audio", isVoid: false) { .SYNOPSIS The URL of the audio to embed. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Src <# diff --git a/src/Elements/New-BaseElement.psm1 b/src/Elements/New-BaseElement.psm1 index 1747ba4..be7a35c 100644 --- a/src/Elements/New-BaseElement.psm1 +++ b/src/Elements/New-BaseElement.psm1 @@ -11,14 +11,13 @@ function New-HtmlBaseElement: NewElementCommand("base", isVoid: true) { .SYNOPSIS The base URL to be used throughout the document for relative URLs. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] [uri] $Href <# .SYNOPSIS The default browsing context to show the results of navigation from elements without explicit `target` attribute. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Target <# diff --git a/src/Elements/New-BlockquoteElement.psm1 b/src/Elements/New-BlockquoteElement.psm1 index 745a292..129c5e3 100644 --- a/src/Elements/New-BlockquoteElement.psm1 +++ b/src/Elements/New-BlockquoteElement.psm1 @@ -11,7 +11,6 @@ function New-HtmlBlockquoteElement: NewElementCommand("blockquote", isVoid: fals .SYNOPSIS A URL that designates a source document or message for the information quoted. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Cite <# diff --git a/src/Elements/New-ButtonElement.psm1 b/src/Elements/New-ButtonElement.psm1 index e2e8fb6..a9304ac 100644 --- a/src/Elements/New-ButtonElement.psm1 +++ b/src/Elements/New-ButtonElement.psm1 @@ -12,42 +12,36 @@ function New-HtmlButtonElement: NewElementCommand("button", isVoid: false) { .SYNOPSIS The action to be performed on an element being controlled via the attribute. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Command <# .SYNOPSIS The identifier of an element to control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $CommandFor <# .SYNOPSIS Value indicating whether to prevent the user from interacting with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Disabled <# .SYNOPSIS The identifier of a `form` element to associate with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Form <# .SYNOPSIS The URL that processes the information submitted by the button. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? FormAction <# .SYNOPSIS Value indicating how to encode the form data that is submitted. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] [string] $FormEnctype @@ -55,7 +49,6 @@ function New-HtmlButtonElement: NewElementCommand("button", isVoid: false) { .SYNOPSIS The HTTP method used to submit the form. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("dialog", "get", "post")] [string] $FormMethod @@ -63,35 +56,30 @@ function New-HtmlButtonElement: NewElementCommand("button", isVoid: false) { .SYNOPSIS Value indicating whether the form is not to be validated when it is submitted. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $FormNoValidate <# .SYNOPSIS The browsing context to show the response after submitting the form. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $FormTarget <# .SYNOPSIS The name of the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# .SYNOPSIS The identifier of a popover element to control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $PopoverTarget <# .SYNOPSIS The action to be performed on a popover element being controlled via the attribute. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("hide", "show", "toggle")] [string] $PopoverTargetAction @@ -99,7 +87,6 @@ function New-HtmlButtonElement: NewElementCommand("button", isVoid: false) { .SYNOPSIS The default behavior of the button. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("button", "reset", "submit")] [string] $Type @@ -107,7 +94,6 @@ function New-HtmlButtonElement: NewElementCommand("button", isVoid: false) { .SYNOPSIS The value of the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [object] $Value <# diff --git a/src/Elements/New-CanvasElement.psm1 b/src/Elements/New-CanvasElement.psm1 index d411e8d..82a29d5 100644 --- a/src/Elements/New-CanvasElement.psm1 +++ b/src/Elements/New-CanvasElement.psm1 @@ -11,14 +11,14 @@ function New-HtmlCanvasElement: NewElementCommand("canvas", isVoid: false) { .SYNOPSIS The height of the coordinate space in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Height = -1; <# .SYNOPSIS The width of the coordinate space in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Width = -1; <# diff --git a/src/Elements/New-ColElement.psm1 b/src/Elements/New-ColElement.psm1 index 9d51593..ba97e9b 100644 --- a/src/Elements/New-ColElement.psm1 +++ b/src/Elements/New-ColElement.psm1 @@ -11,7 +11,7 @@ function New-HtmlColElement: NewElementCommand("col", isVoid: true) { .SYNOPSIS The number of consecutive columns the element spans. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + [ValidateRange(ValidateRangeKind.Positive)] int Span <# diff --git a/src/Elements/New-ColGroupElement.psm1 b/src/Elements/New-ColGroupElement.psm1 index a522bac..6f3ffc7 100644 --- a/src/Elements/New-ColGroupElement.psm1 +++ b/src/Elements/New-ColGroupElement.psm1 @@ -11,7 +11,7 @@ function New-HtmlColgroupElement: NewElementCommand("colgroup", isVoid: false) { .SYNOPSIS The number of consecutive columns the element spans. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + [ValidateRange(ValidateRangeKind.Positive)] int Span <# diff --git a/src/Elements/New-DataElement.psm1 b/src/Elements/New-DataElement.psm1 index cafd702..a88b43b 100644 --- a/src/Elements/New-DataElement.psm1 +++ b/src/Elements/New-DataElement.psm1 @@ -11,7 +11,7 @@ function New-HtmlDataElement: NewElementCommand("data", isVoid: false) { .SYNOPSIS The machine-readable translation of the content of the element. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required string Value <# diff --git a/src/Elements/New-DelElement.psm1 b/src/Elements/New-DelElement.psm1 index a92b5d1..37eca39 100644 --- a/src/Elements/New-DelElement.psm1 +++ b/src/Elements/New-DelElement.psm1 @@ -11,14 +11,12 @@ function New-HtmlDelElement: NewElementCommand("del", isVoid: false) { .SYNOPSIS A URI for a resource that explains the change. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Cite <# .SYNOPSIS The date and time of the change. #> - [Parameter(ValueFromPipelineByPropertyName)] [object] $DateTime <# diff --git a/src/Elements/New-DetailsElement.psm1 b/src/Elements/New-DetailsElement.psm1 index 45a0c5c..c0d05b0 100644 --- a/src/Elements/New-DetailsElement.psm1 +++ b/src/Elements/New-DetailsElement.psm1 @@ -11,14 +11,12 @@ function New-HtmlDetailsElement: NewElementCommand("details", isVoid: false) { .SYNOPSIS The group name allowing multiple `details` elements to be connected, with only one open at a time. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# .SYNOPSIS Value indicating whether the details are currently visible. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Open <# diff --git a/src/Elements/New-DialogElement.psm1 b/src/Elements/New-DialogElement.psm1 index 1292122..e1501dd 100644 --- a/src/Elements/New-DialogElement.psm1 +++ b/src/Elements/New-DialogElement.psm1 @@ -11,7 +11,6 @@ function New-HtmlDialogElement: NewElementCommand("dialog", isVoid: false) { .SYNOPSIS Specifies the types of user actions that can be used to close the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("any", "closerequest", "none")] [string] $ClosedBy @@ -19,7 +18,6 @@ function New-HtmlDialogElement: NewElementCommand("dialog", isVoid: false) { .SYNOPSIS Value indicating whether the dialog box is active and is available for interaction. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Open <# diff --git a/src/Elements/New-EmbedElement.psm1 b/src/Elements/New-EmbedElement.psm1 index 26c4f0d..e1c8095 100644 --- a/src/Elements/New-EmbedElement.psm1 +++ b/src/Elements/New-EmbedElement.psm1 @@ -11,28 +11,28 @@ function New-HtmlEmbedElement: NewElementCommand("embed", isVoid: true) { .SYNOPSIS The displayed height of the resource, in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Height = -1; <# .SYNOPSIS The URL of the resource being embedded. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required Uri Src <# .SYNOPSIS The media type to use, optionally including a `codecs` parameter. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required string Type <# .SYNOPSIS The displayed height of the resource, in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Width = -1; <# diff --git a/src/Elements/New-FieldsetElement.psm1 b/src/Elements/New-FieldsetElement.psm1 index 9e63677..ec65af0 100644 --- a/src/Elements/New-FieldsetElement.psm1 +++ b/src/Elements/New-FieldsetElement.psm1 @@ -11,21 +11,18 @@ function New-HtmlFieldsetElement: NewElementCommand("fieldset", isVoid: false) { .SYNOPSIS Value indicating whether all form controls that are descendants of the element, are disabled. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Disabled <# .SYNOPSIS The identifier of a `form` element to associate with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Form <# .SYNOPSIS The name associated with the group. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# diff --git a/src/Elements/New-FormElement.psm1 b/src/Elements/New-FormElement.psm1 index 32c7181..faba6dc 100644 --- a/src/Elements/New-FormElement.psm1 +++ b/src/Elements/New-FormElement.psm1 @@ -12,14 +12,12 @@ function New-HtmlFormElement: NewElementCommand("form", isVoid: false) { .SYNOPSIS The URL that processes the form submission. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Action <# .SYNOPSIS Value indicating whether input elements can by default have their values automatically completed by the browser. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("off", "on")] [string] $AutoComplete @@ -27,7 +25,6 @@ function New-HtmlFormElement: NewElementCommand("form", isVoid: false) { .SYNOPSIS The media type of the form submission. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] [string] $Enctype @@ -35,7 +32,6 @@ function New-HtmlFormElement: NewElementCommand("form", isVoid: false) { .SYNOPSIS The HTTP method to submit the form with. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("dialog", "get", "post")] [string] $Method @@ -43,28 +39,24 @@ function New-HtmlFormElement: NewElementCommand("form", isVoid: false) { .SYNOPSIS The name of the form. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# .SYNOPSIS Value indicating whether the form shouldn't be validated when submitted. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $NoValidate <# .SYNOPSIS The annotations and what kinds of links the form creates. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $Rel = @(), <# .SYNOPSIS The browsing context to show the response after submitting the form. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Target <# diff --git a/src/Elements/New-IframeElement.psm1 b/src/Elements/New-IframeElement.psm1 index 789496e..cbe55ae 100644 --- a/src/Elements/New-IframeElement.psm1 +++ b/src/Elements/New-IframeElement.psm1 @@ -11,21 +11,19 @@ function New-HtmlIframeElement: NewElementCommand("iframe", isVoid: false) { .SYNOPSIS Specifies a permissions policy thaht defines what features are available to the frame based on the origin of the request. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Allow <# .SYNOPSIS The height of the frame in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Height = -1; <# .SYNOPSIS Value indicating how the browser should load the frame. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("eager", "lazy")] [string] $Loading @@ -33,14 +31,12 @@ function New-HtmlIframeElement: NewElementCommand("iframe", isVoid: false) { .SYNOPSIS A targetable name for the embedded browsing context. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# .SYNOPSIS Value indicating which referrer to send when fetching the frame's resource. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet( "no-referrer-when-downgrade", "no-referrer", "origin-when-cross-origin", "origin", "same-origin", "strict-origin-when-cross-origin", "strict-origin", "unsafe-url" @@ -51,21 +47,20 @@ function New-HtmlIframeElement: NewElementCommand("iframe", isVoid: false) { .SYNOPSIS The restrictions applied to the content embedded in the frame. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $Sandbox = @(), <# .SYNOPSIS The URL of the page to embed. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required Uri Src <# .SYNOPSIS The width of the frame in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Width = -1; <# diff --git a/src/Elements/New-ImgElement.psm1 b/src/Elements/New-ImgElement.psm1 index a39d81e..c75648c 100644 --- a/src/Elements/New-ImgElement.psm1 +++ b/src/Elements/New-ImgElement.psm1 @@ -11,14 +11,13 @@ function New-HtmlImgElement: NewElementCommand("img", isVoid: true) { .SYNOPSIS A text to display on browsers that do not display images. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Alt <# .SYNOPSIS The intrinsic height of the image, in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Height = -1; <# @@ -32,7 +31,6 @@ function New-HtmlImgElement: NewElementCommand("img", isVoid: true) { .SYNOPSIS Value indicating how the browser should load the image. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("eager", "lazy")] [string] $Loading @@ -40,35 +38,32 @@ function New-HtmlImgElement: NewElementCommand("img", isVoid: true) { .SYNOPSIS The intended display sizes of the image. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $Sizes = @(), <# .SYNOPSIS The image URL. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required Uri Src <# .SYNOPSIS The possible image sources for the user agent to use. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $SrcSet = @(), <# .SYNOPSIS The partial URL (starting with `#`) of an image map associated with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $UseMap <# .SYNOPSIS The intrinsic width of the image, in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Width = -1; <# diff --git a/src/Elements/New-InputElement.psm1 b/src/Elements/New-InputElement.psm1 index 83348b4..4217183 100644 --- a/src/Elements/New-InputElement.psm1 +++ b/src/Elements/New-InputElement.psm1 @@ -13,7 +13,6 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { Defines which file types are selectable in a file upload control. /// Valid for the `file` input type only. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Accept <# @@ -21,21 +20,18 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { A text to display on browsers that do not display images. /// Valid for the `image` input type only. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Alt <# .SYNOPSIS A hint for a user agent's autocomplete feature. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $AutoComplete = @(), <# .SYNOPSIS Value indicating which camera to use for capture of image or video data. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("environment", "user")] [string] $Capture @@ -43,28 +39,24 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { .SYNOPSIS Value indicating whether the checkbox is checked or the radio button is the currently selected one. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Checked <# .SYNOPSIS The field name to use for sending the element's directionality in form submission. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $DirName <# .SYNOPSIS Value indicating whether to prevent the user from interacting with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Disabled <# .SYNOPSIS The identifier of a `form` element to associate with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Form <# @@ -72,7 +64,6 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { The URL that processes the information submitted by the button. /// Valid for the `image` and `submit` input types only. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? FormAction <# @@ -80,7 +71,6 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { Value indicating how to encode the form data that is submitted. /// Valid for the `image` and `submit` input types only. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet(MediaTypeNames.Application.FormUrlEncoded, MediaTypeNames.Multipart.FormData, MediaTypeNames.Text.Plain)] [string] $FormEnctype @@ -89,7 +79,6 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { The HTTP method used to submit the form. /// Valid for the `image` and `submit` input types only. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("dialog", "get", "post")] [string] $FormMethod @@ -98,7 +87,6 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { Value indicating whether the form is not to be validated when it is submitted. /// Valid for the `image` and `submit` input types only. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $FormNoValidate <# @@ -106,7 +94,6 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { The browsing context to show the response after submitting the form. /// Valid for the `image` and `submit` input types only. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $FormTarget <# @@ -114,84 +101,77 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { The intrinsic height of the image, in CSS pixels. /// Valid for the `image` input type only. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Height = -1; <# .SYNOPSIS The identifier of a `datalist` element located in the same document.. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $List <# .SYNOPSIS The greatest value in the range of permitted values. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] [string] $Max <# .SYNOPSIS The maximum string length that the user can enter. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int MaxLength = -1; <# .SYNOPSIS The lowest value in the range of permitted values. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] [string] $Min <# .SYNOPSIS The minimum string length required that the user should enter. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int MinLength = -1; <# .SYNOPSIS Value indicating whether the user can enter comma separated email addresses in the `email` widget or can choose more than one file with the `file` input. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Multiple <# .SYNOPSIS The name of the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# .SYNOPSIS The regular expression that the must match in order for the value to pass constraint validation. #> - [Parameter(ValueFromPipelineByPropertyName)] Regex? Pattern <# .SYNOPSIS A hint to the user of what can be entered in the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Placeholder <# .SYNOPSIS The identifier of a popover element to control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $PopoverTarget <# .SYNOPSIS The action to be performed on a popover element being controlled via the attribute. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("hide", "show", "toggle")] [string] $PopoverTargetAction @@ -199,21 +179,19 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { .SYNOPSIS Value indicating whether the user cannot modify the value of the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $ReadOnly <# .SYNOPSIS Value indicating whether the user must fill in a value before submitting a form. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Required <# .SYNOPSIS Value indicating how much of the input is shown. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + [ValidateRange(ValidateRangeKind.Positive)] int Size <# @@ -221,21 +199,19 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { The URL of the image file to display to represent the graphical button. /// Valid for the `image` input type only. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Src <# .SYNOPSIS A number that specifies the granularity that the value must adhere to, or the special value `any`. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] [string] $Step <# .SYNOPSIS The type of control to render. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet( "button", "checkbox", "color", "date", "datetime-local", "email", "file", "hidden", "image", "month", "number", "password", @@ -248,7 +224,6 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { .SYNOPSIS The value of the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [object] $Value <# @@ -256,7 +231,7 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { The intrinsic width of the image, in CSS pixels. /// Valid for the `image` input type only. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Width = -1; <# diff --git a/src/Elements/New-InsElement.psm1 b/src/Elements/New-InsElement.psm1 index 5db1e0d..d03eddd 100644 --- a/src/Elements/New-InsElement.psm1 +++ b/src/Elements/New-InsElement.psm1 @@ -11,14 +11,12 @@ function New-HtmlInsElement: NewElementCommand("ins", isVoid: false) { .SYNOPSIS A URI for a resource that explains the change. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Cite <# .SYNOPSIS The date and time of the change. #> - [Parameter(ValueFromPipelineByPropertyName)] [object] $DateTime <# diff --git a/src/Elements/New-LabelElement.psm1 b/src/Elements/New-LabelElement.psm1 index 3870e8c..abf6a95 100644 --- a/src/Elements/New-LabelElement.psm1 +++ b/src/Elements/New-LabelElement.psm1 @@ -11,7 +11,6 @@ function New-HtmlLabelElement: NewElementCommand("label", isVoid: false) { .SYNOPSIS The identifier of the labelable form control in the same document. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $For <# diff --git a/src/Elements/New-LiElement.psm1 b/src/Elements/New-LiElement.psm1 index 41831d4..d9a0dce 100644 --- a/src/Elements/New-LiElement.psm1 +++ b/src/Elements/New-LiElement.psm1 @@ -11,7 +11,6 @@ function New-HtmlLiElement: NewElementCommand("li", isVoid: false) { .SYNOPSIS The ordinal value of the list item as defined by the `ol` element. #> - [Parameter(ValueFromPipelineByPropertyName)] [int] $Value <# diff --git a/src/Elements/New-LinkElement.psm1 b/src/Elements/New-LinkElement.psm1 index 070479a..edbb4b3 100644 --- a/src/Elements/New-LinkElement.psm1 +++ b/src/Elements/New-LinkElement.psm1 @@ -11,14 +11,12 @@ function New-HtmlLinkElement: NewElementCommand("link", isVoid: true) { .SYNOPSIS Specifies the type of content being loaded by the `link`. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $As <# .SYNOPSIS Value indicating whether CORS must be used when fetching the resource. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("anonymous", "use-credentials")] [string] $CrossOrigin @@ -26,42 +24,38 @@ function New-HtmlLinkElement: NewElementCommand("link", isVoid: true) { .SYNOPSIS The URL of the linked resource. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] [uri] $Href <# .SYNOPSIS A base64-encoded cryptographic hash of the resource (file) to fetch. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Integrity <# .SYNOPSIS The media that the linked resource applies to. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Media <# .SYNOPSIS The relationship of the linked resource to the current document. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required [string[]] $Rel <# .SYNOPSIS The sizes of the icons for visual media contained in the resource. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $Sizes = @(), <# .SYNOPSIS The media type of the content linked to. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Type <# diff --git a/src/Elements/New-MapElement.psm1 b/src/Elements/New-MapElement.psm1 index 8a96585..1d60a86 100644 --- a/src/Elements/New-MapElement.psm1 +++ b/src/Elements/New-MapElement.psm1 @@ -11,7 +11,6 @@ function New-HtmlMapElement: NewElementCommand("map", isVoid: false) { .SYNOPSIS The map name so that it can be referenced. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# diff --git a/src/Elements/New-MetaElement.psm1 b/src/Elements/New-MetaElement.psm1 index 077a9e9..975682e 100644 --- a/src/Elements/New-MetaElement.psm1 +++ b/src/Elements/New-MetaElement.psm1 @@ -11,29 +11,29 @@ function New-HtmlMetaElement: NewElementCommand("meta", isVoid: true) { .SYNOPSIS A charset declaration, giving the character encoding in which the document is encoded. #> - [Parameter(Mandatory, ParameterSetName = nameof(Charset), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(Charset))] required string Charset <# .SYNOPSIS Contains the value for the `http-equiv` or `name attribute`, depending on which is used. #> - [Parameter(Mandatory, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName)] - [Parameter(Mandatory, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(HttpEquiv))] + [Parameter(Mandatory, ParameterSetName = nameof(Name))] override [object] $Content { get => base.Content; set => base.Content = value; } <# .SYNOPSIS A pragma directive to simulate directives that could otherwise be given by an HTTP header. #> - [Parameter(Mandatory, ParameterSetName = nameof(HttpEquiv), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(HttpEquiv))] required string HttpEquiv <# .SYNOPSIS Document-level metadata that applies to the whole page. #> - [Parameter(Mandatory, ParameterSetName = nameof(Name), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(Name))] required string Name <# diff --git a/src/Elements/New-MeterElement.psm1 b/src/Elements/New-MeterElement.psm1 index 2cb21dd..abcf834 100644 --- a/src/Elements/New-MeterElement.psm1 +++ b/src/Elements/New-MeterElement.psm1 @@ -11,42 +11,36 @@ function New-HtmlMeterElement: NewElementCommand("meter", isVoid: false) { .SYNOPSIS The lower numeric bound of the high end of the measured range. #> - [Parameter(ValueFromPipelineByPropertyName)] double? High <# .SYNOPSIS The upper numeric bound of the low end of the measured range. #> - [Parameter(ValueFromPipelineByPropertyName)] double? Low <# .SYNOPSIS The upper numeric bound of the measured range. #> - [Parameter(ValueFromPipelineByPropertyName)] double? Max <# .SYNOPSIS The lower numeric bound of the measured range. #> - [Parameter(ValueFromPipelineByPropertyName)] double? Min <# .SYNOPSIS The optimal numeric value. #> - [Parameter(ValueFromPipelineByPropertyName)] double? Optimum <# .SYNOPSIS The current numeric value. #> - [Parameter(ValueFromPipelineByPropertyName)] double? Value <# diff --git a/src/Elements/New-ObjectElement.psm1 b/src/Elements/New-ObjectElement.psm1 index 2f2af12..151faf7 100644 --- a/src/Elements/New-ObjectElement.psm1 +++ b/src/Elements/New-ObjectElement.psm1 @@ -11,42 +11,40 @@ function New-HtmlObjectElement: NewElementCommand("object", isVoid: false) { .SYNOPSIS The URL of the resource being embedded. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required Uri Data <# .SYNOPSIS The identifier of a `form` element to associate with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Form <# .SYNOPSIS The height of the display resource, in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Height = -1; <# .SYNOPSIS The name of valid browsing context (HTML 5), or the name of the control (HTML 4). #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# .SYNOPSIS The media type to use, optionally including a `codecs` parameter. #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required string Type <# .SYNOPSIS The width of the display resource, in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Width = -1; <# diff --git a/src/Elements/New-OlElement.psm1 b/src/Elements/New-OlElement.psm1 index 88f529a..a6a90eb 100644 --- a/src/Elements/New-OlElement.psm1 +++ b/src/Elements/New-OlElement.psm1 @@ -11,21 +11,18 @@ function New-HtmlOlElement: NewElementCommand("ol", isVoid: false) { .SYNOPSIS Value indicating whether the list's items are in reverse order. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Reversed <# .SYNOPSIS An integer to start counting from for the list items. #> - [Parameter(ValueFromPipelineByPropertyName)] [int] $Start <# .SYNOPSIS Value indicating the current ordinal value of the list item as defined by the `ol` element. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("1", "A", "a", "I", "i")] [string] $Type diff --git a/src/Elements/New-OptgroupElement.psm1 b/src/Elements/New-OptgroupElement.psm1 index 682dd0b..5098e46 100644 --- a/src/Elements/New-OptgroupElement.psm1 +++ b/src/Elements/New-OptgroupElement.psm1 @@ -11,14 +11,12 @@ function New-HtmlOptgroupElement: NewElementCommand("optgroup", isVoid: false) { .SYNOPSIS Value indicating whether none of the items in the option group is selectable. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Disabled <# .SYNOPSIS The name of the group of options. #> - [Parameter(ValueFromPipelineByPropertyName)] required string Label <# diff --git a/src/Elements/New-OptionElement.psm1 b/src/Elements/New-OptionElement.psm1 index a44db72..7e46ffd 100644 --- a/src/Elements/New-OptionElement.psm1 +++ b/src/Elements/New-OptionElement.psm1 @@ -11,28 +11,24 @@ function New-HtmlOptionElement: NewElementCommand("option", isVoid: false) { .SYNOPSIS Value indicating whether the option is not checkable. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Disabled <# .SYNOPSIS The label indicating the meaning of the option. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Label <# .SYNOPSIS Value indicating whether the option is initially selected. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Selected <# .SYNOPSIS The value to be submitted with the form. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Value <# diff --git a/src/Elements/New-OutputElement.psm1 b/src/Elements/New-OutputElement.psm1 index 691be9e..6472a12 100644 --- a/src/Elements/New-OutputElement.psm1 +++ b/src/Elements/New-OutputElement.psm1 @@ -11,21 +11,18 @@ function New-HtmlOutputElement: NewElementCommand("output", isVoid: false) { .SYNOPSIS A list of other elements' identifiers, indicating that those elements contributed input values to the calculation. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $For = @(), <# .SYNOPSIS The identifier of a `form` element to associate with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Form <# .SYNOPSIS The element's name. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# diff --git a/src/Elements/New-ProgressElement.psm1 b/src/Elements/New-ProgressElement.psm1 index 7094983..2c4bdd0 100644 --- a/src/Elements/New-ProgressElement.psm1 +++ b/src/Elements/New-ProgressElement.psm1 @@ -11,14 +11,14 @@ function New-HtmlProgressElement: NewElementCommand("progress", isVoid: false) { .SYNOPSIS Describes how much work the task requires. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] double? Max <# .SYNOPSIS Specifies how much of the task that has been completed. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] double? Value <# diff --git a/src/Elements/New-QElement.psm1 b/src/Elements/New-QElement.psm1 index ad2218b..39a8283 100644 --- a/src/Elements/New-QElement.psm1 +++ b/src/Elements/New-QElement.psm1 @@ -11,7 +11,6 @@ function New-HtmlQElement: NewElementCommand("q", isVoid: false) { .SYNOPSIS A URL that designates a source document or message for the information quoted. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Cite <# diff --git a/src/Elements/New-ScriptElement.psm1 b/src/Elements/New-ScriptElement.psm1 index 6a23880..4f35743 100644 --- a/src/Elements/New-ScriptElement.psm1 +++ b/src/Elements/New-ScriptElement.psm1 @@ -11,14 +11,12 @@ function New-HtmlScriptElement: NewElementCommand("script", isVoid: false) { .SYNOPSIS Value indicating whether the script will be fetched in parallel to parsing and evaluated as soon as it is available. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Async <# .SYNOPSIS Value indicating whether CORS must be used when fetching the resource. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("anonymous", "use-credentials")] [string] $CrossOrigin @@ -26,28 +24,24 @@ function New-HtmlScriptElement: NewElementCommand("script", isVoid: false) { .SYNOPSIS Value indicating whether the script is meant to be executed after the document has been parsed, but before firing `DOMContentLoaded` event. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Defer <# .SYNOPSIS A base64-encoded cryptographic hash of the resource (file) to fetch. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Integrity <# .SYNOPSIS The URI of an external script. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Src <# .SYNOPSIS The type of script represented. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Type <# diff --git a/src/Elements/New-SelectElement.psm1 b/src/Elements/New-SelectElement.psm1 index 8e70254..0beb864 100644 --- a/src/Elements/New-SelectElement.psm1 +++ b/src/Elements/New-SelectElement.psm1 @@ -11,49 +11,43 @@ function New-HtmlSelectElement: NewElementCommand("select", isVoid: false) { .SYNOPSIS A hint for a user agent's autocomplete feature. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $AutoComplete = @(), <# .SYNOPSIS Value indicating whether to prevent the user from interacting with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Disabled <# .SYNOPSIS The identifier of a `form` element to associate with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Form <# .SYNOPSIS Value indicating whether multiple options can be selected in the list. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Multiple <# .SYNOPSIS The name of the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# .SYNOPSIS Value indicating whether an option with a non-empty string value must be selected. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Required <# .SYNOPSIS The number of rows in the list that should be visible at one time. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Size = -1; <# diff --git a/src/Elements/New-SlotElement.psm1 b/src/Elements/New-SlotElement.psm1 index afa97dd..e95a55c 100644 --- a/src/Elements/New-SlotElement.psm1 +++ b/src/Elements/New-SlotElement.psm1 @@ -11,7 +11,6 @@ function New-HtmlSlotElement: NewElementCommand("slot", isVoid: false) { .SYNOPSIS The slot's name. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# diff --git a/src/Elements/New-SourceElement.psm1 b/src/Elements/New-SourceElement.psm1 index ed97cf6..9a1e22b 100644 --- a/src/Elements/New-SourceElement.psm1 +++ b/src/Elements/New-SourceElement.psm1 @@ -11,49 +11,48 @@ function New-HtmlSourceElement: NewElementCommand("source", isVoid: true) { .SYNOPSIS The intrinsic height of the image, in CSS pixels. #> - [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [Parameter(ParameterSetName = nameof(SrcSet)), ValidateRange(ValidateRangeKind.NonNegative)] int Height = -1; <# .SYNOPSIS The media query for the resource's intended media. #> - [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = nameof(SrcSet))] [string] $Media <# .SYNOPSIS A list of source sizes that describe the final rendered width of the image. #> - [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = nameof(SrcSet))] [string[]] $Sizes = @(), <# .SYNOPSIS The URL of the media resource #> - [Parameter(Mandatory, ParameterSetName = nameof(Src), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(Src))] required Uri Src <# .SYNOPSIS A list of one or more image URLs and their descriptors. #> - [Parameter(Mandatory, ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = nameof(SrcSet))] [string[]] $SrcSet = @(), <# .SYNOPSIS The media type to use, optionally including a `codecs` parameter. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Type <# .SYNOPSIS The intrinsic width of the image, in CSS pixels. #> - [Parameter(ParameterSetName = nameof(SrcSet), ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [Parameter(ParameterSetName = nameof(SrcSet)), ValidateRange(ValidateRangeKind.NonNegative)] int Width = -1; <# diff --git a/src/Elements/New-StyleElement.psm1 b/src/Elements/New-StyleElement.psm1 index 85b36ae..cf1b596 100644 --- a/src/Elements/New-StyleElement.psm1 +++ b/src/Elements/New-StyleElement.psm1 @@ -11,7 +11,6 @@ function New-HtmlStyleElement: NewElementCommand("style", isVoid: false) { .SYNOPSIS Defines which media the style should be applied to. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Media <# diff --git a/src/Elements/New-TdElement.psm1 b/src/Elements/New-TdElement.psm1 index c034589..5cbc351 100644 --- a/src/Elements/New-TdElement.psm1 +++ b/src/Elements/New-TdElement.psm1 @@ -11,21 +11,20 @@ function New-HtmlTdElement: NewElementCommand("td", isVoid: false) { .SYNOPSIS An integer indicating how many columns the header cell spans or extends. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int ColSpan = -1; <# .SYNOPSIS A list of strings corresponding to the `id` attributes of the `th` elements that provide the headers for this header cell. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $Headers = @(), <# .SYNOPSIS An integer indicating how many rows the header cell spans or extends. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int RowSpan = -1; <# diff --git a/src/Elements/New-TemplateElement.psm1 b/src/Elements/New-TemplateElement.psm1 index cb1389a..3e93bfe 100644 --- a/src/Elements/New-TemplateElement.psm1 +++ b/src/Elements/New-TemplateElement.psm1 @@ -11,21 +11,18 @@ function New-HtmlTemplateElement: NewElementCommand("template", isVoid: false) { .SYNOPSIS Value indicating whether the shadow root is clonable. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $ShadowRootClonable <# .SYNOPSIS Value indicating whether the shadow root delegates focus. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $ShadowRootDelegatesFocus <# .SYNOPSIS Value indicating whether to create a shadow root for the parent element. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("closed", "open")] [string] $ShadowRootMode @@ -33,7 +30,6 @@ function New-HtmlTemplateElement: NewElementCommand("template", isVoid: false) { .SYNOPSIS Value indicating whether the shadow root is serializable. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $ShadowRootSerializable <# diff --git a/src/Elements/New-TextareaElement.psm1 b/src/Elements/New-TextareaElement.psm1 index d9b7d7d..b0c842a 100644 --- a/src/Elements/New-TextareaElement.psm1 +++ b/src/Elements/New-TextareaElement.psm1 @@ -11,14 +11,12 @@ function New-HtmlTextareaElement: NewElementCommand("textarea", isVoid: false) { .SYNOPSIS A hint for a user agent's autocomplete feature. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $AutoComplete = @(), <# .SYNOPSIS Value indicating whether automatic spelling correction and processing of text is enabled. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("off", "on")] [string] $AutoCorrect @@ -26,84 +24,76 @@ function New-HtmlTextareaElement: NewElementCommand("textarea", isVoid: false) { .SYNOPSIS The visible width of the text control, in average character widths. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + [ValidateRange(ValidateRangeKind.Positive)] int Cols <# .SYNOPSIS The field name to use for sending the element's directionality in form submission. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $DirName <# .SYNOPSIS Value indicating whether to prevent the user from interacting with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Disabled <# .SYNOPSIS The identifier of a `form` element to associate with the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Form <# .SYNOPSIS The maximum string length that the user can enter. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int MaxLength = -1; <# .SYNOPSIS The minimum string length required that the user should enter. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int MinLength = -1; <# .SYNOPSIS The name of the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Name <# .SYNOPSIS A hint to the user of what can be entered in the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Placeholder <# .SYNOPSIS Value indicating whether the user cannot modify the value of the control. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $ReadOnly <# .SYNOPSIS Value indicating whether the user must fill in a value before submitting a form. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Required <# .SYNOPSIS The number of visible text lines for the control. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.Positive)] + [ValidateRange(ValidateRangeKind.Positive)] int Rows <# .SYNOPSIS Value indicating whether the control should wrap the value for form submission. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("hard", "soft")] [string] $Wrap diff --git a/src/Elements/New-ThElement.psm1 b/src/Elements/New-ThElement.psm1 index 2e4aeb9..67dbd86 100644 --- a/src/Elements/New-ThElement.psm1 +++ b/src/Elements/New-ThElement.psm1 @@ -11,35 +11,32 @@ function New-HtmlThElement: NewElementCommand("th", isVoid: false) { .SYNOPSIS A short, abbreviated description of the header cell's content provided as an alternative label to use for the header cell when referencing the cell in other contexts. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Abbr <# .SYNOPSIS An integer indicating how many columns the header cell spans or extends. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int ColSpan = -1; <# .SYNOPSIS A list of strings corresponding to the `id` attributes of the `th` elements that provide the headers for this header cell. #> - [Parameter(ValueFromPipelineByPropertyName)] [string[]] $Headers = @(), <# .SYNOPSIS An integer indicating how many rows the header cell spans or extends. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int RowSpan = -1; <# .SYNOPSIS Defines the cells that the header element relates to. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("col", "colgroup", "row", "rowgroup")] [string] $Scope diff --git a/src/Elements/New-TimeElement.psm1 b/src/Elements/New-TimeElement.psm1 index 8dd07e9..e82323d 100644 --- a/src/Elements/New-TimeElement.psm1 +++ b/src/Elements/New-TimeElement.psm1 @@ -12,7 +12,6 @@ function New-HtmlTimeElement: NewElementCommand("time", isVoid: false) { .SYNOPSIS The time and/or date of the element. #> - [Parameter(ValueFromPipelineByPropertyName)] [object] $DateTime <# diff --git a/src/Elements/New-TrackElement.psm1 b/src/Elements/New-TrackElement.psm1 index 5f2745e..ea31831 100644 --- a/src/Elements/New-TrackElement.psm1 +++ b/src/Elements/New-TrackElement.psm1 @@ -11,14 +11,12 @@ function New-HtmlTrackElement: NewElementCommand("track", isVoid: true) { .SYNOPSIS Value indicating whether the track should be enabled unless the user's preferences indicate that another track is more appropriate. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Default <# .SYNOPSIS Value indicating how the text track is meant to be used. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("captions", "chapters", "descriptions", "metadata", "subtitles")] [string] $Kind @@ -26,21 +24,19 @@ function New-HtmlTrackElement: NewElementCommand("track", isVoid: true) { .SYNOPSIS A user-readable title of the text track which is used by the browser when listing available text tracks. #> - [Parameter(ValueFromPipelineByPropertyName)] [string] $Label <# .SYNOPSIS The address of the track (`.vtt` file). #> - [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [Parameter(Mandatory)] required Uri Src <# .SYNOPSIS The language of the track text data. #> - [Parameter(ValueFromPipelineByPropertyName)] [cultureinfo] $SrcLang <# diff --git a/src/Elements/New-VideoElement.psm1 b/src/Elements/New-VideoElement.psm1 index c51674f..470fdf5 100644 --- a/src/Elements/New-VideoElement.psm1 +++ b/src/Elements/New-VideoElement.psm1 @@ -11,21 +11,18 @@ function New-HtmlVideoElement: NewElementCommand("video", isVoid: false) { .SYNOPSIS Value indicating whether playback should start automatically as soon as the video signal allows. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $AutoPlay <# .SYNOPSIS Value indicating whether to offer controls to allow the user to control video playback. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Controls <# .SYNOPSIS Value indicating whether CORS must be used when fetching the resource. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("anonymous", "use-credentials")] [string] $CrossOrigin @@ -33,56 +30,49 @@ function New-HtmlVideoElement: NewElementCommand("video", isVoid: false) { .SYNOPSIS Value indicating whether to prevent the browser from suggesting a Picture-in-Picture context menu or to request Picture-in-Picture automatically. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $DisablePictureInPicture <# .SYNOPSIS Value indicating whether to disable the capability of remote playback in devices that are attached using wired and wireless technologies. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $DisableRemotePlayback <# .SYNOPSIS The height of the video's display area, in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Height = -1; <# .SYNOPSIS Value indicating whether the video player will automatically seek back to the start upon reaching the end of the video. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Loop <# .SYNOPSIS Value indicating whether the audio will be initially silenced. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $Muted <# .SYNOPSIS Value indicating whether the video is to be played "inline", that is, within the element's playback area. #> - [Parameter(ValueFromPipelineByPropertyName)] [switch] $PlaysInline <# .SYNOPSIS The URL for an image to be shown while the video is downloading. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Poster <# .SYNOPSIS Value providing a hint to the browser about what the author thinks will lead to the best user experience. #> - [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet("auto", "none", "metadata")] [string] $Preload @@ -90,14 +80,13 @@ function New-HtmlVideoElement: NewElementCommand("video", isVoid: false) { .SYNOPSIS The URL of the video to embed. #> - [Parameter(ValueFromPipelineByPropertyName)] Uri? Src <# .SYNOPSIS The width of the video's display area, in CSS pixels. #> - [Parameter(ValueFromPipelineByPropertyName), ValidateRange(ValidateRangeKind.NonNegative)] + [ValidateRange(ValidateRangeKind.NonNegative)] int Width = -1; <# From 7489f363dc4b2f2f3e06993117d0a93065075615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 15:44:10 +0200 Subject: [PATCH 18/23] Add the `New-HtmlElement` cmdlet --- share/Cmdlet.Template.psm1 | 3 +- src/New-Element.cs | 211 --------------------------- src/New-Element.psm1 | 139 ++++++++++++++++++ test/Elements/New-AElement.Tests.ps1 | 7 +- 4 files changed, 144 insertions(+), 216 deletions(-) delete mode 100644 src/New-Element.cs create mode 100644 src/New-Element.psm1 diff --git a/share/Cmdlet.Template.psm1 b/share/Cmdlet.Template.psm1 index b2d9fad..d54d89f 100644 --- a/share/Cmdlet.Template.psm1 +++ b/share/Cmdlet.Template.psm1 @@ -12,11 +12,10 @@ function New-Html{CapitalizedTag}Element { [OutputType([string])] param ( # The inner HTML of the element. - [Parameter(Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [Parameter(Position = 0, ValueFromPipeline)] [object] $Content, # The custom attributes to render. - [Parameter(ValueFromPipelineByPropertyName)] [hashtable] $Attributes = @{} ) diff --git a/src/New-Element.cs b/src/New-Element.cs deleted file mode 100644 index f81ce8c..0000000 --- a/src/New-Element.cs +++ /dev/null @@ -1,211 +0,0 @@ -namespace Belin.Html; - -using System.Collections; -using System.Globalization; -using System.Net; -using System.Text; -using System.Text.Json; - -/// -/// Provides the abstract base class for a cmdlet rendering an HTML element. -/// -/// The tag name of the element to create. -/// Value indicating whether the element to create is a void element. -public abstract class NewElementCommand(string tagName, bool isVoid = false): PSCmdlet { - - /// - /// The HTML-encoded string corresponding to a double quote. - /// - private static readonly string encodedDoubleQuote = WebUtility.HtmlEncode("\""); - - /// - /// The custom attributes to render. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Hashtable Attributes { get; set; } = []; - - /// - /// Value indicating whether inputted text is automatically capitalized. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("characters", "none", "off", "on", "sentences", "words")] - public string? AutoCapitalize { get; set; } - - /// - /// Value indicating whether the element should have input focus when the page loads. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter AutoFocus { get; set; } - - /// - /// The CSS class names applied to the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string[] Class { get; set; } = []; - - /// - /// The inner HTML of the element. - /// - [Parameter(Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] - public virtual object? Content { get; set; } - - /// - /// Value indicating whether the element is editable by the user. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("false", "plaintext-only", "true")] - public string? ContentEditable { get; set; } - - /// - /// The data attributes to render. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Hashtable DataSet { get; set; } = []; - - /// - /// The directionality of the element's text. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("auto", "ltr", "rtl")] - public string? Dir { get; set; } - - /// - /// Value indicating whether the element can be dragged. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("false", "true")] - public string? Draggable { get; set; } - - /// - /// Value indicating whether the browser should not render the contents of the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public SwitchParameter Hidden { get; set; } - - /// - /// The element identifier. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Id { get; set; } - - /// - /// A hint at the type of data that might be entered by the user while editing the element or its contents. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("decimal", "email", "none", "numeric", "search", "tel", "text", "url")] - public string? InputMode { get; set; } - - /// - /// The element's language. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public CultureInfo? Lang { get; set; } - - /// - /// Value indicating whether the element is a popover element. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("auto", "hint", "manual")] - public string? Popover { get; set; } - - /// - /// The event handler attributes to render. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public Hashtable On { get; set; } = []; - - /// - /// Value indicating whether the element is subject to spell-checking by the underlying browser/OS. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("false", "true")] - public string? SpellCheck { get; set; } - - /// - /// The CSS styling declarations applied to the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public OrderedHashtable Style { get; set; } = []; - - /// - /// Determines the relative ordering of the element for sequential focus navigation. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public int? TabIndex { get; set; } - - /// - /// A text representing advisory information related to the element. - /// - [Parameter(ValueFromPipelineByPropertyName = true)] - public string? Title { get; set; } - - /// - /// Value indicating whether the element's text should be translated when the page is localized. - /// - [Parameter(ValueFromPipelineByPropertyName = true), ValidateSet("no", "yes")] - public string? Translate { get; set; } - - /// - /// Value indicating whether the element to create is a void element. - /// - protected bool IsVoid { get; set; } = isVoid; - - /// - /// The tag name of the element to create. - /// - protected string TagName { get; set; } = tagName; - - /// - /// Performs execution of this command. - /// - protected override void ProcessRecord() { - var attributes = Attributes.Cast().ToDictionary(entry => entry.Key.ToString() ?? "", entry => entry.Value, StringComparer.OrdinalIgnoreCase); - RenderAttributes(attributes); - - var builder = new StringBuilder($"<{TagName}"); - foreach (var (key, value) in attributes.Where(attribute => attribute.Value is not null)) { - if (value is bool booleanValue) { - if (booleanValue) builder.Append($" {key}"); - } - else if (value is SwitchParameter switchParameter) { - if (switchParameter.IsPresent) builder.Append($" {key}"); - } - else { - var stringValue = Convert.ToString(value, CultureInfo.InvariantCulture)?.Replace("\"", encodedDoubleQuote); - builder.Append($" {key}=\"{stringValue}\""); - } - } - - if (IsVoid) builder.Append('>'); - else { - var output = Content is ScriptBlock scriptBlock ? scriptBlock.Invoke().Select(psObject => psObject.BaseObject) : (Content is not null ? [Content] : []); - builder.Append('>'); - foreach (var value in output) builder.Append(value); - builder.Append($""); - } - - WriteObject(builder.ToString()); - } - - /// - /// Populates the specified attribute collection with the element attributes. - /// - /// The attribute collection to populate. - protected virtual void RenderAttributes(IDictionary attributes) { - var kebabCase = JsonNamingPolicy.KebabCaseLower.ConvertName; - - if (!string.IsNullOrWhiteSpace(Id)) attributes["id"] = Id; - if (AutoCapitalize is not null) attributes["autocapitalize"] = AutoCapitalize; - if (AutoFocus) attributes["autofocus"] = true; - if (Class.Length > 0) attributes["class"] = string.Join(' ', Class).Trim(); - if (ContentEditable is not null) attributes["contenteditable"] = ContentEditable; - foreach (DictionaryEntry entry in DataSet) attributes[$"data-{kebabCase(entry.Key.ToString() ?? "")}"] = entry.Value; - if (Dir is not null) attributes["dir"] = Dir; - if (Draggable is not null) attributes["draggable"] = Draggable; - if (Hidden) attributes["hidden"] = true; - if (InputMode is not null) attributes["inputmode"] = InputMode; - if (Lang is not null) attributes["lang"] = Lang.Name; - foreach (DictionaryEntry entry in On) attributes[$"on{entry.Key.ToString()?.ToLowerInvariant()}"] = entry.Value; - if (Popover is not null) attributes["popover"] = Popover; - if (SpellCheck is not null) attributes["spellcheck"] = SpellCheck; - if (TabIndex is not null) attributes["tabindex"] = TabIndex.Value.ToString(CultureInfo.InvariantCulture); - if (!string.IsNullOrWhiteSpace(Title)) attributes["title"] = Title; - if (Translate is not null) attributes["translate"] = Translate; - - if (Style.Count > 0) attributes["style"] = string.Join("; ", Style.Cast() - .Select(entry => $"{kebabCase(entry.Key.ToString() ?? "")}: {Convert.ToString(entry.Value, CultureInfo.InvariantCulture)?.Replace("\"", encodedDoubleQuote)}")); - } -} diff --git a/src/New-Element.psm1 b/src/New-Element.psm1 new file mode 100644 index 0000000..eadaff4 --- /dev/null +++ b/src/New-Element.psm1 @@ -0,0 +1,139 @@ +using namespace System.Collections.Specialized +using namespace System.Net +using namespace System.Text +using module ./Format-KebabCase.psm1 + +<# +.SYNOPSIS + The HTML-encoded string corresponding to a double quote. +#> +$EncodedDoubleQuote = [WebUtility]::HtmlEncode('"') + +<# +.SYNOPSIS + Creates a new HTML element. +.OUTPUTS + The newly created HTML element. +#> +function New-HtmlElement { + [CmdletBinding()] + [OutputType([string])] + param ( + # The tag name of the element to create. + [Parameter(Mandatory)] + [string] $TagName, + + # The inner HTML of the element. + [Parameter(Position = 0, ValueFromPipeline)] + [object] $Content, + + # The custom attributes to render. + [hashtable] $Attributes = @{}, + + # Value indicating whether inputted text is automatically capitalized. + [ValidateSet("characters", "none", "off", "on", "sentences", "words")] + [string] $AutoCapitalize, + + # Value indicating whether the element should have input focus when the page loads. + [switch] $AutoFocus, + + # The CSS class names applied to the element. + [string[]] $Class = @(), + + # Value indicating whether the element is editable by the user. + [ValidateSet("false", "plaintext-only", "true")] + [string] $ContentEditable, + + # The data attributes to render. + [hashtable] $Data = @{}, + + # The directionality of the element's text. + [ValidateSet("auto", "ltr", "rtl")] + [string] $Dir, + + # Value indicating whether the element can be dragged. + [ValidateSet("false", "true")] + [string] $Draggable, + + # Value indicating whether the browser should not render the contents of the element. + [switch] $Hidden, + + # The element identifier. + [string] $Id, + + # A hint at the type of data that might be entered by the user while editing the element or its contents. + [ValidateSet("decimal", "email", "none", "numeric", "search", "tel", "text", "url")] + [string] $InputMode, + + # The element's language. + [cultureinfo] $Lang, + + # Value indicating whether the element is a popover element. + [ValidateSet("auto", "hint", "manual")] + [string] $Popover, + + # The event handler attributes to render. + [hashtable] $On = @{}, + + # Value indicating whether the element is subject to spell-checking by the underlying browser/OS. + [ValidateSet("false", "true")] + [string] $SpellCheck, + + # The CSS styling declarations applied to the element. + [OrderedDictionary] $Style = [ordered]@{}, + + # Determines the relative ordering of the element for sequential focus navigation. + [int] $TabIndex, + + # A text representing advisory information related to the element. + [string] $Title, + + # Value indicating whether the element's text should be translated when the page is localized. + [ValidateSet("no", "yes")] + [string] $Translate, + + # Value indicating whether the element to create is a void element. + [switch] $Void + ) + + process { + if ($Id) { $Attributes["id"] = $Id } + if ($AutoCapitalize) { $Attributes["autocapitalize"] = $AutoCapitalize } + if ($AutoFocus) { $Attributes["autofocus"] = $true } + if ($Class.Count) { $Attributes["class"] = ($Class -join " ").Trim() } + if ($ContentEditable) { $Attributes["contenteditable"] = $ContentEditable } + $Data.Keys.ForEach{ $Attributes["data-$(Format-KebabCase $_)"] = $Data.$_ } # TODO test numbers with comma / ToString() conversion + if ($Dir) { $Attributes["dir"] = $Dir } + if ($Draggable) { $Attributes["draggable"] = $Draggable } + if ($Hidden) { $Attributes["hidden"] = $true } + if ($InputMode) { $Attributes["inputmode"] = $InputMode } + if ($Lang) { $Attributes["lang"] = $Lang.Name } + $On.Keys.ForEach{ $Attributes["on$(([string] $_).ToLowerInvariant())"] = $On.$_ } # TODO test numbers with comma / ToString() conversion, double-quotes, etc. + if ($Popover) { $Attributes["popover"] = $Popover } + if ($SpellCheck) { $Attributes["spellcheck"] = $SpellCheck } + if ($Style.Count) { $Attributes["style"] = $Style.ForEach{ "$(Format-KebabCase $_.Key): $($_.Value)" } -join "; " } # TODO test numbers with comma / ToString() conversion, double-quotes, etc. + if ($TabIndex) { $Attributes["tabindex"] = $TabIndex } + if ($Title) { $Attributes["title"] = $Title } + if ($Translate) { $Attributes["translate"] = $Translate } + + # TODO test numbers with comma / ToString() conversion, double-quotes, etc. + $builder = [StringBuilder] "<$TagName" + foreach ($key in $Attributes.Keys) { + switch ($Attributes.$key) { + { $null -eq $_ } { break } + { $_ -is [bool] } { if ($_) { $builder.Append(" $key") | Out-Null }; break } + { $_ -is [switch] } { if ($_.IsPresent) { $builder.Append(" $key") | Out-Null }; break } + default { $builder.Append(" $key=""$(([string] $_).Replace('"', $Script:EncodedDoubleQuote))""") | Out-Null } + } + } + + $builder.Append(">") | Out-Null + if (-not $Void) { + $output = $Content -is [scriptblock] ? (& $Content) : ($null -ne $Content ? @($Content) : @()) + foreach ($value in $output) { $builder.Append($value) | Out-Null } + $builder.Append("") | Out-Null + } + + $builder.ToString() + } +} diff --git a/test/Elements/New-AElement.Tests.ps1 b/test/Elements/New-AElement.Tests.ps1 index 9841f87..4cc3250 100644 --- a/test/Elements/New-AElement.Tests.ps1 +++ b/test/Elements/New-AElement.Tests.ps1 @@ -17,16 +17,17 @@ Describe "New-AElement" { } It 'should support the "ping" attribute' { - $expected = '', 'Click me' + $expected = '', '' a -href Index.html -ping "https://example.com/", Tracking.php | Should -BeIn $expected } It 'should support the "rel" attribute' { - $expected = '', 'Click me' + $expected = '', '' a -href Index.html -rel external, nofollow | Should -BeIn $expected } It 'should support the "target" attribute' -ForEach "_blank", "my-iframe" { - a "Click me" -href Index.html -target $_ | Should -BeExactly "Click me" + $expected = "Click me", "Click me" + a "Click me" -href Index.html -target $_ | Should -BeIn $expected } } From fa88047d11dbad1eaf318304a05975575d52a7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 17:23:02 +0200 Subject: [PATCH 19/23] Update the changelog --- ChangeLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 3354d8b..d6c59ac 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Changelog +## Version [2.0.0](https://github.com/cedx/html.ps1/compare/v1.2.0...v2.0.0) +- Breaking change: ported the source code to [PowerShell](https://learn.microsoft.com/en-us/powershell). +- Breaking change: renamed the `-DataSet` parameter to `-Data`. + ## Version [1.2.0](https://github.com/cedx/html.ps1/compare/v1.1.0...v1.2.0) - Added the `Use-Layout` and `Write-View` cmdlets. From aa96d2fc9364808e8ab101e43982fae0ddb1b91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 18:42:35 +0200 Subject: [PATCH 20/23] Port the `New-HtmlCustomElement` cmdlet --- Html.psd1 | 339 +------------------------------------ src/New-CustomElement.cs | 26 --- src/New-CustomElement.psm1 | 36 ++++ tool/Build.ps1 | 6 +- 4 files changed, 45 insertions(+), 362 deletions(-) delete mode 100644 src/New-CustomElement.cs create mode 100644 src/New-CustomElement.psm1 diff --git a/Html.psd1 b/Html.psd1 index ec86634..d4408f7 100644 --- a/Html.psd1 +++ b/Html.psd1 @@ -13,348 +13,21 @@ VariablesToExport = @() AliasesToExport = @( + "doctype" "a" - "abbr" - "address" - "area" - "article" - "aside" - "audio" - "b" - "base" - "bdi" - "bdo" - "blockquote" - "body" - "br" - "button" - "canvas" - "caption" - "cite" - "code" - "col" - "colgroup" - "data" - "datalist" - "dd" - "delTag" - "details" - "dfn" - "dialog" - "div" - "dl" - "dt" - "em" - "embed" - "fieldset" - "figcaption" - "figure" - "footer" - "form" - "h1" - "h2" - "h3" - "h4" - "h5" - "h6" - "head" - "header" - "hgroup" - "hr" - "html" - "i" - "iframe" - "img" - "input" - "ins" - "kbd" - "label" - "legend" - "li" - "link" - "main" - "map" - "mark" - "menu" - "meta" - "meter" - "nav" - "noscript" - "object" - "ol" - "optgroup" - "option" - "output" - "p" - "picture" - "pre" - "progress" - "q" - "rpTag" - "rt" - "ruby" - "s" - "samp" - "script" - "search" - "section" - "selectTag" - "slot" - "small" - "source" - "span" - "strong" - "style" - "sub" - "summary" - "sup" - "table" - "tbody" - "td" - "template" - "textarea" - "tfoot" - "th" - "thead" - "time" - "title" - "tr" - "track" - "u" - "ul" - "var" - "video" - "wbr" + "tag" ) FunctionsToExport = @( - "New-HtmlAbbrElement" - "New-HtmlAddressElement" "New-HtmlAElement" - "New-HtmlAreaElement" - "New-HtmlArticleElement" - "New-HtmlAsideElement" - "New-HtmlAudioElement" - "New-HtmlBaseElement" - "New-HtmlBdiElement" - "New-HtmlBdoElement" - "New-HtmlBElement" - "New-HtmlBlockquoteElement" - "New-HtmlBodyElement" - "New-HtmlBrElement" - "New-HtmlButtonElement" - "New-HtmlCanvasElement" - "New-HtmlCaptionElement" - "New-HtmlCiteElement" - "New-HtmlCodeElement" - "New-HtmlColElement" - "New-HtmlColgroupElement" - "New-HtmlDataElement" - "New-HtmlDatalistElement" - "New-HtmlDdElement" - "New-HtmlDelElement" - "New-HtmlDetailsElement" - "New-HtmlDfnElement" - "New-HtmlDialogElement" - "New-HtmlDivElement" - "New-HtmlDlElement" - "New-HtmlDtElement" - "New-HtmlEmbedElement" - "New-HtmlEmElement" - "New-HtmlFieldsetElement" - "New-HtmlFigcaptionElement" - "New-HtmlFigureElement" - "New-HtmlFooterElement" - "New-HtmlFormElement" - "New-HtmlH1Element" - "New-HtmlH2Element" - "New-HtmlH3Element" - "New-HtmlH4Element" - "New-HtmlH5Element" - "New-HtmlH6Element" - "New-HtmlHeadElement" - "New-HtmlHeaderElement" - "New-HtmlHgroupElement" - "New-HtmlHrElement" - "New-HtmlHtmlElement" - "New-HtmlIElement" - "New-HtmlIframeElement" - "New-HtmlImgElement" - "New-HtmlInputElement" - "New-HtmlInsElement" - "New-HtmlKbdElement" - "New-HtmlLabelElement" - "New-HtmlLegendElement" - "New-HtmlLiElement" - "New-HtmlLinkElement" - "New-HtmlMainElement" - "New-HtmlMapElement" - "New-HtmlMarkElement" - "New-HtmlMenuElement" - "New-HtmlMetaElement" - "New-HtmlMeterElement" - "New-HtmlNavElement" - "New-HtmlNoscriptElement" - "New-HtmlObjectElement" - "New-HtmlOlElement" - "New-HtmlOptgroupElement" - "New-HtmlOptionElement" - "New-HtmlOutputElement" - "New-HtmlPElement" - "New-HtmlPictureElement" - "New-HtmlPreElement" - "New-HtmlProgressElement" - "New-HtmlQElement" - "New-HtmlRpElement" - "New-HtmlRtElement" - "New-HtmlRubyElement" - "New-HtmlSampElement" - "New-HtmlScriptElement" - "New-HtmlSearchElement" - "New-HtmlSectionElement" - "New-HtmlSelectElement" - "New-HtmlSElement" - "New-HtmlSlotElement" - "New-HtmlSmallElement" - "New-HtmlSourceElement" - "New-HtmlSpanElement" - "New-HtmlStrongElement" - "New-HtmlStyleElement" - "New-HtmlSubElement" - "New-HtmlSummaryElement" - "New-HtmlSupElement" - "New-HtmlTableElement" - "New-HtmlTbodyElement" - "New-HtmlTdElement" - "New-HtmlTemplateElement" - "New-HtmlTextareaElement" - "New-HtmlTfootElement" - "New-HtmlTheadElement" - "New-HtmlThElement" - "New-HtmlTimeElement" - "New-HtmlTitleElement" - "New-HtmlTrackElement" - "New-HtmlTrElement" - "New-HtmlUElement" - "New-HtmlUlElement" - "New-HtmlVarElement" - "New-HtmlVideoElement" - "New-HtmlWbrElement" + "New-HtmlDocumentType" + "New-HtmlCustomElement" ) NestedModules = @( "src/Elements/New-AElement.psm1" - "src/Elements/New-AreaElement.psm1" - "src/Elements/New-AudioElement.psm1" - "src/Elements/New-BaseElement.psm1" - "src/Elements/New-BlockquoteElement.psm1" - "src/Elements/New-ButtonElement.psm1" - "src/Elements/New-CanvasElement.psm1" - "src/Elements/New-ColElement.psm1" - "src/Elements/New-ColgroupElement.psm1" - "src/Elements/New-DataElement.psm1" - "src/Elements/New-DelElement.psm1" - "src/Elements/New-DetailsElement.psm1" - "src/Elements/New-DialogElement.psm1" - "src/Elements/New-EmbedElement.psm1" - "src/Elements/New-FieldsetElement.psm1" - "src/Elements/New-FormElement.psm1" - "src/Elements/New-IframeElement.psm1" - "src/Elements/New-ImgElement.psm1" - "src/Elements/New-InputElement.psm1" - "src/Elements/New-InsElement.psm1" - "src/Elements/New-LabelElement.psm1" - "src/Elements/New-LiElement.psm1" - "src/Elements/New-LinkElement.psm1" - "src/Elements/New-MapElement.psm1" - "src/Elements/New-MetaElement.psm1" - "src/Elements/New-MeterElement.psm1" - "src/Elements/New-ObjectElement.psm1" - "src/Elements/New-OlElement.psm1" - "src/Elements/New-OptgroupElement.psm1" - "src/Elements/New-OptionElement.psm1" - "src/Elements/New-OutputElement.psm1" - "src/Elements/New-ProgressElement.psm1" - "src/Elements/New-QElement.psm1" - "src/Elements/New-ScriptElement.psm1" - "src/Elements/New-SelectElement.psm1" - "src/Elements/New-SlotElement.psm1" - "src/Elements/New-SourceElement.psm1" - "src/Elements/New-StyleElement.psm1" - "src/Elements/New-TdElement.psm1" - "src/Elements/New-TemplateElement.psm1" - "src/Elements/New-TextareaElement.psm1" - "src/Elements/New-ThElement.psm1" - "src/Elements/New-TimeElement.psm1" - "src/Elements/New-TrackElement.psm1" - "src/Elements/New-VideoElement.psm1" - "src/Generated/New-AbbrElement.g.psm1" - "src/Generated/New-AddressElement.g.psm1" - "src/Generated/New-ArticleElement.g.psm1" - "src/Generated/New-AsideElement.g.psm1" - "src/Generated/New-BdiElement.g.psm1" - "src/Generated/New-BdoElement.g.psm1" - "src/Generated/New-BElement.g.psm1" - "src/Generated/New-BodyElement.g.psm1" - "src/Generated/New-BrElement.g.psm1" - "src/Generated/New-CaptionElement.g.psm1" - "src/Generated/New-CiteElement.g.psm1" - "src/Generated/New-CodeElement.g.psm1" - "src/Generated/New-DatalistElement.g.psm1" - "src/Generated/New-DdElement.g.psm1" - "src/Generated/New-DfnElement.g.psm1" - "src/Generated/New-DivElement.g.psm1" - "src/Generated/New-DlElement.g.psm1" - "src/Generated/New-DtElement.g.psm1" - "src/Generated/New-EmElement.g.psm1" - "src/Generated/New-FigcaptionElement.g.psm1" - "src/Generated/New-FigureElement.g.psm1" - "src/Generated/New-FooterElement.g.psm1" - "src/Generated/New-H1Element.g.psm1" - "src/Generated/New-H2Element.g.psm1" - "src/Generated/New-H3Element.g.psm1" - "src/Generated/New-H4Element.g.psm1" - "src/Generated/New-H5Element.g.psm1" - "src/Generated/New-H6Element.g.psm1" - "src/Generated/New-HeadElement.g.psm1" - "src/Generated/New-HeaderElement.g.psm1" - "src/Generated/New-HgroupElement.g.psm1" - "src/Generated/New-HrElement.g.psm1" - "src/Generated/New-HtmlElement.g.psm1" - "src/Generated/New-IElement.g.psm1" - "src/Generated/New-KbdElement.g.psm1" - "src/Generated/New-LegendElement.g.psm1" - "src/Generated/New-MainElement.g.psm1" - "src/Generated/New-MarkElement.g.psm1" - "src/Generated/New-MenuElement.g.psm1" - "src/Generated/New-NavElement.g.psm1" - "src/Generated/New-NoscriptElement.g.psm1" - "src/Generated/New-PElement.g.psm1" - "src/Generated/New-PictureElement.g.psm1" - "src/Generated/New-PreElement.g.psm1" - "src/Generated/New-RpElement.g.psm1" - "src/Generated/New-RtElement.g.psm1" - "src/Generated/New-RubyElement.g.psm1" - "src/Generated/New-SampElement.g.psm1" - "src/Generated/New-SearchElement.g.psm1" - "src/Generated/New-SectionElement.g.psm1" - "src/Generated/New-SElement.g.psm1" - "src/Generated/New-SmallElement.g.psm1" - "src/Generated/New-SpanElement.g.psm1" - "src/Generated/New-StrongElement.g.psm1" - "src/Generated/New-SubElement.g.psm1" - "src/Generated/New-SummaryElement.g.psm1" - "src/Generated/New-SupElement.g.psm1" - "src/Generated/New-TableElement.g.psm1" - "src/Generated/New-TbodyElement.g.psm1" - "src/Generated/New-TfootElement.g.psm1" - "src/Generated/New-TheadElement.g.psm1" - "src/Generated/New-TitleElement.g.psm1" - "src/Generated/New-TrElement.g.psm1" - "src/Generated/New-UElement.g.psm1" - "src/Generated/New-UlElement.g.psm1" - "src/Generated/New-VarElement.g.psm1" - "src/Generated/New-WbrElement.g.psm1" + "src/New-DocumentType.psm1" + "src/New-CustomElement.psm1" ) PrivateData = @{ diff --git a/src/New-CustomElement.cs b/src/New-CustomElement.cs deleted file mode 100644 index 59f302b..0000000 --- a/src/New-CustomElement.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Belin.Html; - -/// -/// Creates a new custom element. -/// -[Cmdlet(VerbsCommon.New, "HtmlCustomElement"), Alias("tag"), OutputType(typeof(string))] -public class NewCustomElementCommand(): NewElementCommand("", isVoid: false) { - - /// - /// The inner HTML of the element. - /// - [Parameter(Position = 1, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] - public override object? Content { get => base.Content; set => base.Content = value; } - - /// - /// The tag name of the element to create. - /// - [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true)] - public required string Name { get => TagName; set => TagName = value; } - - /// - /// Value indicating whether the element to create is a void element. - /// - [Parameter] - public SwitchParameter Void { get => IsVoid; set => IsVoid = value; } -} diff --git a/src/New-CustomElement.psm1 b/src/New-CustomElement.psm1 new file mode 100644 index 0000000..94bf40c --- /dev/null +++ b/src/New-CustomElement.psm1 @@ -0,0 +1,36 @@ +using module ./New-Element.psm1 + +<# +.SYNOPSIS + Creates a new custom element. +.INPUTS + The inner HTML of the custom element. +.OUTPUTS + The newly created custom element. +#> +function New-HtmlCustomElement { + [Alias("tag")] + [CmdletBinding()] + [OutputType([string])] + param ( + # The tag name of the custom element to create. + [Parameter(Mandatory, Position = 0)] + [ValidateScript({ + $index = $_.IndexOf("-") + ($index -gt 0) -and ($index -lt $_.Length) -and ($_.Length -ge 3) + }, ErrorMessage = "The specified tag name is not a valid custom element name.")] + [string] $TagName, + + # The inner HTML of the element. + [Parameter(Position = 1, ValueFromPipeline)] + [object] $Content, + + # The custom attributes to render. + [hashtable] $Attributes = @{} + ) + + process { + $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $PSBoundParameters.Remove($_) | Out-Null } + New-HtmlElement -TagName $TagName.ToLowerInvariant() -Attributes $Attributes.Clone() -Content $Content @PSBoundParameters + } +} diff --git a/tool/Build.ps1 b/tool/Build.ps1 index 0229f53..b76af26 100644 --- a/tool/Build.ps1 +++ b/tool/Build.ps1 @@ -5,16 +5,16 @@ $cmdlets = [pscustomobject]@{ Aliases = [List[string]]::new([string[]] @( "doctype" # New-HtmlDocumentType # "layout" # Use-HtmlLayout - # "tag" # New-HtmlCustomElement + "tag" # New-HtmlCustomElement )) Functions = [List[string]]::new([string[]] @( - # "New-HtmlCustomElement" + "New-HtmlCustomElement" "New-HtmlDocumentType" # "Use-HtmlLayout" # "Write-HtmlView" )) Modules = [List[string]]::new([string[]] @( - # "src/New-CustomElement.psm1" + "src/New-CustomElement.psm1" "src/New-DocumentType.psm1" # "src/Use-Layout.psm1" # "src/Write-View.psm1" From 30fde70ae3db82318aa293fa1958f32a98ccda94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 18:46:39 +0200 Subject: [PATCH 21/23] Rename the `New-HtmlElement` cmdlet to `Write-HtmlElement` --- ChangeLog.md | 2 +- share/Cmdlet.Template.psm1 | 2 +- src/Elements/New-AElement.psm1 | 4 +- src/Elements/New-AudioElement.psm1 | 2 +- src/Elements/New-BaseElement.psm1 | 2 +- src/Elements/New-BlockquoteElement.psm1 | 2 +- src/Elements/New-ButtonElement.psm1 | 2 +- src/Elements/New-CanvasElement.psm1 | 2 +- src/Elements/New-ColElement.psm1 | 2 +- src/Elements/New-ColGroupElement.psm1 | 2 +- src/Elements/New-DataElement.psm1 | 2 +- src/Elements/New-DelElement.psm1 | 2 +- src/Elements/New-DetailsElement.psm1 | 2 +- src/Elements/New-DialogElement.psm1 | 2 +- src/Elements/New-EmbedElement.psm1 | 2 +- src/Elements/New-FieldsetElement.psm1 | 2 +- src/Elements/New-FormElement.psm1 | 2 +- src/Elements/New-IframeElement.psm1 | 2 +- src/Elements/New-ImgElement.psm1 | 2 +- src/Elements/New-InputElement.psm1 | 2 +- src/Elements/New-InsElement.psm1 | 2 +- src/Elements/New-LabelElement.psm1 | 2 +- src/Elements/New-LiElement.psm1 | 2 +- src/Elements/New-LinkElement.psm1 | 2 +- src/Elements/New-MapElement.psm1 | 2 +- src/Elements/New-MetaElement.psm1 | 2 +- src/Elements/New-MeterElement.psm1 | 2 +- src/Elements/New-ObjectElement.psm1 | 2 +- src/Elements/New-OlElement.psm1 | 2 +- src/Elements/New-OptgroupElement.psm1 | 2 +- src/Elements/New-OptionElement.psm1 | 2 +- src/Elements/New-OutputElement.psm1 | 2 +- src/Elements/New-ProgressElement.psm1 | 2 +- src/Elements/New-QElement.psm1 | 2 +- src/Elements/New-ScriptElement.psm1 | 2 +- src/Elements/New-SelectElement.psm1 | 2 +- src/Elements/New-SlotElement.psm1 | 2 +- src/Elements/New-SourceElement.psm1 | 2 +- src/Elements/New-StyleElement.psm1 | 2 +- src/Elements/New-TdElement.psm1 | 2 +- src/Elements/New-TemplateElement.psm1 | 2 +- src/Elements/New-TextareaElement.psm1 | 2 +- src/Elements/New-ThElement.psm1 | 2 +- src/Elements/New-TimeElement.psm1 | 2 +- src/Elements/New-TrackElement.psm1 | 2 +- src/Elements/New-VideoElement.psm1 | 2 +- src/New-CustomElement.psm1 | 4 +- src/{New-Element.psm1 => Write-Element.psm1} | 2 +- test/New-Element.Tests.ps1 | 4 +- test/Write-Element.Tests.ps1 | 80 ++++++++++++++++++++ 50 files changed, 132 insertions(+), 52 deletions(-) rename src/{New-Element.psm1 => Write-Element.psm1} (99%) create mode 100644 test/Write-Element.Tests.ps1 diff --git a/ChangeLog.md b/ChangeLog.md index d6c59ac..d3be8f9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -57,7 +57,7 @@ - Added the `a`, `area`, `img` and `script` aliases. ## Version [0.2.0](https://github.com/cedx/html.ps1/compare/v0.1.0...v0.2.0) -- Added the `New-BaseElement`, `New-HtmlElement`, `New-LinkElement` and `New-MetaElement` cmdlets. +- Added the `New-BaseElement`, `Write-HtmlElement`, `New-LinkElement` and `New-MetaElement` cmdlets. - Added the `base`, `html`, `link` and `meta` aliases. ## Version 0.1.0 diff --git a/share/Cmdlet.Template.psm1 b/share/Cmdlet.Template.psm1 index d54d89f..97e612a 100644 --- a/share/Cmdlet.Template.psm1 +++ b/share/Cmdlet.Template.psm1 @@ -23,6 +23,6 @@ function New-Html{CapitalizedTag}Element { # TODO handle void elements !!! they don't have content ! $attributesToRender = $Attributes.Clone() $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $PSBoundParameters.Remove($_) | Out-Null } - New-HtmlElement -TagName {Tag} -Attributes $attributesToRender -Content $Content -Void:{IsVoid} @PSBoundParameters + Write-HtmlElement -TagName {Tag} -Attributes $attributesToRender -Content $Content -Void:{IsVoid} @PSBoundParameters } } diff --git a/src/Elements/New-AElement.psm1 b/src/Elements/New-AElement.psm1 index d1299da..1492b7d 100644 --- a/src/Elements/New-AElement.psm1 +++ b/src/Elements/New-AElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS @@ -46,6 +46,6 @@ function New-HtmlAElement { if ($Target) { $attributesToRender.target = $Target } $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $PSBoundParameters.Remove($_) | Out-Null } - New-HtmlElement -TagName a -Attributes $attributesToRender -Content $Content @PSBoundParameters + Write-HtmlElement -TagName a -Attributes $attributesToRender -Content $Content @PSBoundParameters } } diff --git a/src/Elements/New-AudioElement.psm1 b/src/Elements/New-AudioElement.psm1 index 9f1c7c7..7beee0c 100644 --- a/src/Elements/New-AudioElement.psm1 +++ b/src/Elements/New-AudioElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-BaseElement.psm1 b/src/Elements/New-BaseElement.psm1 index be7a35c..b72209b 100644 --- a/src/Elements/New-BaseElement.psm1 +++ b/src/Elements/New-BaseElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-BlockquoteElement.psm1 b/src/Elements/New-BlockquoteElement.psm1 index 129c5e3..51bbbeb 100644 --- a/src/Elements/New-BlockquoteElement.psm1 +++ b/src/Elements/New-BlockquoteElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-ButtonElement.psm1 b/src/Elements/New-ButtonElement.psm1 index a9304ac..12011ff 100644 --- a/src/Elements/New-ButtonElement.psm1 +++ b/src/Elements/New-ButtonElement.psm1 @@ -1,5 +1,5 @@ using namespace System.Net.Mime -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-CanvasElement.psm1 b/src/Elements/New-CanvasElement.psm1 index 82a29d5..8b99214 100644 --- a/src/Elements/New-CanvasElement.psm1 +++ b/src/Elements/New-CanvasElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-ColElement.psm1 b/src/Elements/New-ColElement.psm1 index ba97e9b..4b32640 100644 --- a/src/Elements/New-ColElement.psm1 +++ b/src/Elements/New-ColElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-ColGroupElement.psm1 b/src/Elements/New-ColGroupElement.psm1 index 6f3ffc7..18ac67c 100644 --- a/src/Elements/New-ColGroupElement.psm1 +++ b/src/Elements/New-ColGroupElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-DataElement.psm1 b/src/Elements/New-DataElement.psm1 index a88b43b..96350f1 100644 --- a/src/Elements/New-DataElement.psm1 +++ b/src/Elements/New-DataElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-DelElement.psm1 b/src/Elements/New-DelElement.psm1 index 37eca39..7a4b52a 100644 --- a/src/Elements/New-DelElement.psm1 +++ b/src/Elements/New-DelElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-DetailsElement.psm1 b/src/Elements/New-DetailsElement.psm1 index c0d05b0..351f4c3 100644 --- a/src/Elements/New-DetailsElement.psm1 +++ b/src/Elements/New-DetailsElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-DialogElement.psm1 b/src/Elements/New-DialogElement.psm1 index e1501dd..ddd838d 100644 --- a/src/Elements/New-DialogElement.psm1 +++ b/src/Elements/New-DialogElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-EmbedElement.psm1 b/src/Elements/New-EmbedElement.psm1 index e1c8095..503c784 100644 --- a/src/Elements/New-EmbedElement.psm1 +++ b/src/Elements/New-EmbedElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-FieldsetElement.psm1 b/src/Elements/New-FieldsetElement.psm1 index ec65af0..8a1ba9b 100644 --- a/src/Elements/New-FieldsetElement.psm1 +++ b/src/Elements/New-FieldsetElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-FormElement.psm1 b/src/Elements/New-FormElement.psm1 index faba6dc..7cad0d7 100644 --- a/src/Elements/New-FormElement.psm1 +++ b/src/Elements/New-FormElement.psm1 @@ -1,5 +1,5 @@ using namespace System.Net.Mime -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-IframeElement.psm1 b/src/Elements/New-IframeElement.psm1 index cbe55ae..2439845 100644 --- a/src/Elements/New-IframeElement.psm1 +++ b/src/Elements/New-IframeElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-ImgElement.psm1 b/src/Elements/New-ImgElement.psm1 index c75648c..22dbd06 100644 --- a/src/Elements/New-ImgElement.psm1 +++ b/src/Elements/New-ImgElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-InputElement.psm1 b/src/Elements/New-InputElement.psm1 index 4217183..b00957b 100644 --- a/src/Elements/New-InputElement.psm1 +++ b/src/Elements/New-InputElement.psm1 @@ -1,5 +1,5 @@ using namespace System.Net.Mime -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-InsElement.psm1 b/src/Elements/New-InsElement.psm1 index d03eddd..719e522 100644 --- a/src/Elements/New-InsElement.psm1 +++ b/src/Elements/New-InsElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-LabelElement.psm1 b/src/Elements/New-LabelElement.psm1 index abf6a95..3ef3f05 100644 --- a/src/Elements/New-LabelElement.psm1 +++ b/src/Elements/New-LabelElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-LiElement.psm1 b/src/Elements/New-LiElement.psm1 index d9a0dce..37ea082 100644 --- a/src/Elements/New-LiElement.psm1 +++ b/src/Elements/New-LiElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-LinkElement.psm1 b/src/Elements/New-LinkElement.psm1 index edbb4b3..1813872 100644 --- a/src/Elements/New-LinkElement.psm1 +++ b/src/Elements/New-LinkElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-MapElement.psm1 b/src/Elements/New-MapElement.psm1 index 1d60a86..018f364 100644 --- a/src/Elements/New-MapElement.psm1 +++ b/src/Elements/New-MapElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-MetaElement.psm1 b/src/Elements/New-MetaElement.psm1 index 975682e..d5f05f3 100644 --- a/src/Elements/New-MetaElement.psm1 +++ b/src/Elements/New-MetaElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-MeterElement.psm1 b/src/Elements/New-MeterElement.psm1 index abcf834..4589165 100644 --- a/src/Elements/New-MeterElement.psm1 +++ b/src/Elements/New-MeterElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-ObjectElement.psm1 b/src/Elements/New-ObjectElement.psm1 index 151faf7..ea0de19 100644 --- a/src/Elements/New-ObjectElement.psm1 +++ b/src/Elements/New-ObjectElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-OlElement.psm1 b/src/Elements/New-OlElement.psm1 index a6a90eb..d5a1af3 100644 --- a/src/Elements/New-OlElement.psm1 +++ b/src/Elements/New-OlElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-OptgroupElement.psm1 b/src/Elements/New-OptgroupElement.psm1 index 5098e46..93c375a 100644 --- a/src/Elements/New-OptgroupElement.psm1 +++ b/src/Elements/New-OptgroupElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-OptionElement.psm1 b/src/Elements/New-OptionElement.psm1 index 7e46ffd..d47dc50 100644 --- a/src/Elements/New-OptionElement.psm1 +++ b/src/Elements/New-OptionElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-OutputElement.psm1 b/src/Elements/New-OutputElement.psm1 index 6472a12..b86188e 100644 --- a/src/Elements/New-OutputElement.psm1 +++ b/src/Elements/New-OutputElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-ProgressElement.psm1 b/src/Elements/New-ProgressElement.psm1 index 2c4bdd0..4f7dfc8 100644 --- a/src/Elements/New-ProgressElement.psm1 +++ b/src/Elements/New-ProgressElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-QElement.psm1 b/src/Elements/New-QElement.psm1 index 39a8283..b0bda80 100644 --- a/src/Elements/New-QElement.psm1 +++ b/src/Elements/New-QElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-ScriptElement.psm1 b/src/Elements/New-ScriptElement.psm1 index 4f35743..daf09f7 100644 --- a/src/Elements/New-ScriptElement.psm1 +++ b/src/Elements/New-ScriptElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-SelectElement.psm1 b/src/Elements/New-SelectElement.psm1 index 0beb864..d738f64 100644 --- a/src/Elements/New-SelectElement.psm1 +++ b/src/Elements/New-SelectElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-SlotElement.psm1 b/src/Elements/New-SlotElement.psm1 index e95a55c..305ddcb 100644 --- a/src/Elements/New-SlotElement.psm1 +++ b/src/Elements/New-SlotElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-SourceElement.psm1 b/src/Elements/New-SourceElement.psm1 index 9a1e22b..4484af6 100644 --- a/src/Elements/New-SourceElement.psm1 +++ b/src/Elements/New-SourceElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-StyleElement.psm1 b/src/Elements/New-StyleElement.psm1 index cf1b596..a49cd36 100644 --- a/src/Elements/New-StyleElement.psm1 +++ b/src/Elements/New-StyleElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-TdElement.psm1 b/src/Elements/New-TdElement.psm1 index 5cbc351..6c4f62d 100644 --- a/src/Elements/New-TdElement.psm1 +++ b/src/Elements/New-TdElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-TemplateElement.psm1 b/src/Elements/New-TemplateElement.psm1 index 3e93bfe..000fc53 100644 --- a/src/Elements/New-TemplateElement.psm1 +++ b/src/Elements/New-TemplateElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-TextareaElement.psm1 b/src/Elements/New-TextareaElement.psm1 index b0c842a..e0863ba 100644 --- a/src/Elements/New-TextareaElement.psm1 +++ b/src/Elements/New-TextareaElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-ThElement.psm1 b/src/Elements/New-ThElement.psm1 index 67dbd86..d7aa804 100644 --- a/src/Elements/New-ThElement.psm1 +++ b/src/Elements/New-ThElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-TimeElement.psm1 b/src/Elements/New-TimeElement.psm1 index e82323d..025a30f 100644 --- a/src/Elements/New-TimeElement.psm1 +++ b/src/Elements/New-TimeElement.psm1 @@ -1,5 +1,5 @@ using namespace System.Xml -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-TrackElement.psm1 b/src/Elements/New-TrackElement.psm1 index ea31831..2df1063 100644 --- a/src/Elements/New-TrackElement.psm1 +++ b/src/Elements/New-TrackElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/Elements/New-VideoElement.psm1 b/src/Elements/New-VideoElement.psm1 index 470fdf5..819cdbe 100644 --- a/src/Elements/New-VideoElement.psm1 +++ b/src/Elements/New-VideoElement.psm1 @@ -1,4 +1,4 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS diff --git a/src/New-CustomElement.psm1 b/src/New-CustomElement.psm1 index 94bf40c..17f6b1f 100644 --- a/src/New-CustomElement.psm1 +++ b/src/New-CustomElement.psm1 @@ -1,4 +1,4 @@ -using module ./New-Element.psm1 +using module ./Write-Element.psm1 <# .SYNOPSIS @@ -31,6 +31,6 @@ function New-HtmlCustomElement { process { $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $PSBoundParameters.Remove($_) | Out-Null } - New-HtmlElement -TagName $TagName.ToLowerInvariant() -Attributes $Attributes.Clone() -Content $Content @PSBoundParameters + Write-HtmlElement -TagName $TagName.ToLowerInvariant() -Attributes $Attributes.Clone() -Content $Content @PSBoundParameters } } diff --git a/src/New-Element.psm1 b/src/Write-Element.psm1 similarity index 99% rename from src/New-Element.psm1 rename to src/Write-Element.psm1 index eadaff4..e357ca6 100644 --- a/src/New-Element.psm1 +++ b/src/Write-Element.psm1 @@ -15,7 +15,7 @@ $EncodedDoubleQuote = [WebUtility]::HtmlEncode('"') .OUTPUTS The newly created HTML element. #> -function New-HtmlElement { +function Write-HtmlElement { [CmdletBinding()] [OutputType([string])] param ( diff --git a/test/New-Element.Tests.ps1 b/test/New-Element.Tests.ps1 index 9baad47..10f83a4 100644 --- a/test/New-Element.Tests.ps1 +++ b/test/New-Element.Tests.ps1 @@ -1,8 +1,8 @@ <# .SYNOPSIS - Tests the features of the `New-Element` cmdlet. + Tests the features of the `Write-Element` cmdlet. #> -Describe "New-Element" { +Describe "Write-Element" { BeforeAll { Import-Module "$PSScriptRoot/../Html.psd1" } diff --git a/test/Write-Element.Tests.ps1 b/test/Write-Element.Tests.ps1 new file mode 100644 index 0000000..10f83a4 --- /dev/null +++ b/test/Write-Element.Tests.ps1 @@ -0,0 +1,80 @@ +<# +.SYNOPSIS + Tests the features of the `Write-Element` cmdlet. +#> +Describe "Write-Element" { + BeforeAll { + Import-Module "$PSScriptRoot/../Html.psd1" + } + + It "should create an HTML element from the specified tag name" -ForEach @( + @{ Tag = "b"; Expected = "" } + @{ Tag = "html"; Expected = "" } + ) { + & $tag | Should -BeExactly $expected + } + + It "should handle void elements" -ForEach @( + @{ Tag = "br"; Expected = "
" } + @{ Tag = "input"; Expected = "" } + ) { + & $tag | Should -BeExactly $expected + } + + It 'should handle the "class" attribute' { + body -class btn, btn-danger | Should -BeExactly '' + body -class "btn btn-info", btn-sm | Should -BeExactly '' + } + + It 'should support the "dir" attribute' -ForEach auto, ltr, rtl { + html -dir $_ | Should -BeExactly "" + } + + It 'should handle the "id" attribute' { + article -id foo | Should -BeExactly '
' + } + + It 'should support the "lang" attribute' -ForEach "fr-FR", "en-US" { + html -lang $_ | Should -BeExactly "" + } + + It 'should handle the "style" attribute' { + $expected = '' + code -style ([ordered]@{ FontFamily = '"Segoe UI"'; FontSize = "1rem" }) | Should -BeExactly $expected + } + + It 'should handle the "tabindex" attribute' -ForEach -1, 0 { + div -tabindex $_ | Should -BeExactly "
" + } + + It 'should handle the "title" attribute' -ForEach "", 'A "custom" label.' { + div -title $_ | Should -BeExactly ($_ ? '
' : "
") + } + + It "should handle custom attributes" { + $expected = '', '' + input -attributes @{ "data-foo" = '"bar"'; disabled = $false; required = $true } | Should -BeIn $expected + } + + It "should handle data attributes" { + $expected = '', '' + button -dataset @{ BsToggle = "tooltip"; PushUrl = $true } | Should -BeIn $expected + } + + It "should handle event handler attributes" { + $expected = '', '' + button -on @{ Click = "submit(event)"; ContextMenu = "showMenu()" } | Should -BeIn $expected + } + + It "should handle switch parameters in attribute values" { + input -attributes @{ disabled = [switch] $false; required = [switch] $true } | Should -BeExactly "" + } + + It "should handle the inner content" { + $expected = "
Foo > Bar Baz < Qux
" + main { div { "Foo > Bar"; " "; span "Baz < Qux" } } | Should -BeExactly $expected + + $expected = '' + head { meta -charset utf-8 } | Should -BeExactly $expected + } +} From 60bb53a859a1673581664f1464d71b9b5a7dc60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 19:01:08 +0200 Subject: [PATCH 22/23] Code formatting --- res/Content.ps1 | 2 +- res/Footer.ps1 | 2 +- res/Header.ps1 | 14 ++-- res/Layout.ps1 | 22 +++--- test/Elements/New-AElement.Tests.ps1 | 10 +-- test/Elements/New-AreaElement.Tests.ps1 | 2 +- test/Elements/New-BaseElement.Tests.ps1 | 4 +- test/Elements/New-ButtonElement.Tests.ps1 | 2 +- test/Elements/New-CanvasElement.Tests.ps1 | 4 +- test/Elements/New-DetailsElement.Tests.ps1 | 2 +- test/Elements/New-EmbedElement.Tests.ps1 | 2 +- test/Elements/New-FormElement.Tests.ps1 | 4 +- test/Elements/New-IframeElement.Tests.ps1 | 8 +-- test/Elements/New-ImgElement.Tests.ps1 | 12 ++-- test/Elements/New-InputElement.Tests.ps1 | 2 +- test/Elements/New-LinkElement.Tests.ps1 | 12 ++-- test/Elements/New-MapElement.Tests.ps1 | 2 +- test/Elements/New-MetaElement.Tests.ps1 | 6 +- test/Elements/New-ObjectElement.Tests.ps1 | 2 +- test/Elements/New-OlElement.Tests.ps1 | 2 +- test/Elements/New-ScriptElement.Tests.ps1 | 6 +- test/Elements/New-SlotElement.Tests.ps1 | 2 +- test/Elements/New-SourceElement.Tests.ps1 | 2 +- test/Elements/New-TemplateElement.Tests.ps1 | 2 +- test/Elements/New-TrackElement.Tests.ps1 | 4 +- test/Elements/New-VideoElement.Tests.ps1 | 2 +- test/New-CustomElement.Tests.ps1 | 22 +++--- test/New-DocumentType.Tests.ps1 | 2 +- test/New-Element.Tests.ps1 | 80 --------------------- test/Use-Layout.Tests.ps1 | 2 +- test/Write-Element.Tests.ps1 | 26 +++---- 31 files changed, 91 insertions(+), 175 deletions(-) delete mode 100644 test/New-Element.Tests.ps1 diff --git a/res/Content.ps1 b/res/Content.ps1 index 0536746..a72f016 100644 --- a/res/Content.ps1 +++ b/res/Content.ps1 @@ -1,4 +1,4 @@ param ([hashtable] $data) h1 $data.Title -div -class alert, alert-success "Welcome to my website!" +div -Class alert, alert-success "Welcome to my website!" diff --git a/res/Footer.ps1 b/res/Footer.ps1 index ba18bae..aafa71e 100644 --- a/res/Footer.ps1 +++ b/res/Footer.ps1 @@ -1,5 +1,5 @@ param ([hashtable] $data) -footer -class text-center { +footer -Class text-center { "Copyright © $($data.Year) - All rights reserved." } diff --git a/res/Header.ps1 b/res/Header.ps1 index 41cff9e..655ad44 100644 --- a/res/Header.ps1 +++ b/res/Header.ps1 @@ -1,15 +1,15 @@ param ([hashtable] $data) header { - nav -class navbar, navbar-expand-xl { - div -class container-fluid { - button -class navbar-toggler -dataset @{ BsTarget = "#menu"; BsToggle = "offcanvas" } { - span -class navbar-toggler-icon + nav -Class navbar, navbar-expand-xl { + div -Class container-fluid { + button -Class navbar-toggler -Data @{ BsTarget = "#menu"; BsToggle = "offcanvas" } { + span -Class navbar-toggler-icon } - div -class navbar-brand, d-flex, align-items-center { - a -href Index.html { img -alt "" -src Favicon.ico -width 30 -height 30 } - div -class ms-2 $data.AppName + div -Class navbar-brand, d-flex, align-items-center { + a -Href Index.html { img -Alt "" -Src Favicon.ico -Width 30 -Height 30 } + div -Class ms-2 $data.AppName } } } diff --git a/res/Layout.ps1 b/res/Layout.ps1 index 18ed2ae..34221aa 100644 --- a/res/Layout.ps1 +++ b/res/Layout.ps1 @@ -1,22 +1,22 @@ param ([string] $content, [hashtable] $data) doctype -html -lang $PSCulture { +html -Lang $PSCulture { head { - meta -charset utf-8 + meta -Charset utf-8 title $data.AppName - meta -name color-scheme -content light - meta -name viewport -content "initial-scale=1, width=device-width" + meta -Name color-scheme -Content light + meta -Name viewport -Content "initial-scale=1, width=device-width" - link -rel icon -href Favicon.ico - link -rel preload -href Assets/Font.woff2 -as font -crossorigin anonymous -type font/woff2 + link -Rel icon -Href Favicon.ico + link -Rel preload -Href Assets/Font.woff2 -As font -CrossOrigin anonymous -Type font/woff2 - link -rel stylesheet -href "https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.css" -integrity "sha256-2FMn2Zx6PuH5tdBQDRNwrOo60ts5wWPC9R8jK67b3t4" - link -rel stylesheet -href Assets/Styles.css + link -Rel stylesheet -Href "https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.css" -Integrity "sha256-2FMn2Zx6PuH5tdBQDRNwrOo60ts5wWPC9R8jK67b3t4" + link -Rel stylesheet -Href Assets/Styles.css - script -src "https://cdn.jsdelivr.net/npm/bootstrap@5/dist/js/bootstrap.js" -integrity "sha256-ew8UiV1pJH/YjpOEBInP1HxVvT/SfrCmwSoUzF9JIgc=" - script -src Assets/Scripts.js -type module + script -Src "https://cdn.jsdelivr.net/npm/bootstrap@5/dist/js/bootstrap.js" -Integrity "sha256-ew8UiV1pJH/YjpOEBInP1HxVvT/SfrCmwSoUzF9JIgc=" + script -Src Assets/Scripts.js -Type module } body { @@ -24,7 +24,7 @@ html -lang $PSCulture { main { noscript { p "This application requires $(b JavaScript) to be enabled in your browser." } - article -class container-xl { $content } + article -Class container-xl { $content } } & "$PSScriptRoot/Footer.ps1" @{ Year = $data.Year } diff --git a/test/Elements/New-AElement.Tests.ps1 b/test/Elements/New-AElement.Tests.ps1 index 4cc3250..d2c269c 100644 --- a/test/Elements/New-AElement.Tests.ps1 +++ b/test/Elements/New-AElement.Tests.ps1 @@ -9,25 +9,25 @@ Describe "New-AElement" { It 'should support the "download" attribute' { $expected = 'Click me', 'Click me' - a "Click me" -href Index.html -download Evil.js | Should -BeIn $expected + a "Click me" -Href Index.html -Download Evil.js | Should -BeIn $expected } It 'should support the "href" attribute' -ForEach "./Index.html", "mailto:dummy@example.com", "tel:+33123456789" { - a "Click me" -href $_ | Should -BeExactly "Click me" + a "Click me" -Href $_ | Should -BeExactly "Click me" } It 'should support the "ping" attribute' { $expected = '', '' - a -href Index.html -ping "https://example.com/", Tracking.php | Should -BeIn $expected + a -Href Index.html -Ping "https://example.com/", Tracking.php | Should -BeIn $expected } It 'should support the "rel" attribute' { $expected = '', '' - a -href Index.html -rel external, nofollow | Should -BeIn $expected + a -Href Index.html -Rel external, nofollow | Should -BeIn $expected } It 'should support the "target" attribute' -ForEach "_blank", "my-iframe" { $expected = "Click me", "Click me" - a "Click me" -href Index.html -target $_ | Should -BeIn $expected + a "Click me" -Href Index.html -Target $_ | Should -BeIn $expected } } diff --git a/test/Elements/New-AreaElement.Tests.ps1 b/test/Elements/New-AreaElement.Tests.ps1 index fef9f54..042fc48 100644 --- a/test/Elements/New-AreaElement.Tests.ps1 +++ b/test/Elements/New-AreaElement.Tests.ps1 @@ -8,7 +8,7 @@ Describe "New-AreaElement" { } It 'should support the "shape" and "coords" attributes' { - $area = area -href Index.html -shape circle -coords 100, 200, 64.7 + $area = area -Href Index.html -shape circle -coords 100, 200, 64.7 $area | Should -BeLikeExactly "" + base -Href $_ | Should -BeExactly "" } It 'should support the "target" attribute' -ForEach "_blank", "my-iframe" { - base -href /base/ -target $_ | Should -BeExactly "" + base -Href /base/ -Target $_ | Should -BeExactly "" } } diff --git a/test/Elements/New-ButtonElement.Tests.ps1 b/test/Elements/New-ButtonElement.Tests.ps1 index a770353..9f1a90c 100644 --- a/test/Elements/New-ButtonElement.Tests.ps1 +++ b/test/Elements/New-ButtonElement.Tests.ps1 @@ -21,6 +21,6 @@ Describe "New-ButtonElement" { } It 'should support the "type" attribute' -ForEach button, reset, submit { - button -type $_ | Should -BeExactly "" + button -Type $_ | Should -BeExactly "" } } diff --git a/test/Elements/New-CanvasElement.Tests.ps1 b/test/Elements/New-CanvasElement.Tests.ps1 index a395c69..0f2d24b 100644 --- a/test/Elements/New-CanvasElement.Tests.ps1 +++ b/test/Elements/New-CanvasElement.Tests.ps1 @@ -8,7 +8,7 @@ Describe "New-CanvasElement" { } It 'should support the "height" and "width" attributes' { - canvas -height 200 | Should -BeExactly '' - canvas -width 460 | Should -BeExactly '' + canvas -Height 200 | Should -BeExactly '' + canvas -Width 460 | Should -BeExactly '' } } diff --git a/test/Elements/New-DetailsElement.Tests.ps1 b/test/Elements/New-DetailsElement.Tests.ps1 index 99470ea..1f1a4c0 100644 --- a/test/Elements/New-DetailsElement.Tests.ps1 +++ b/test/Elements/New-DetailsElement.Tests.ps1 @@ -8,7 +8,7 @@ Describe "New-DetailsElement" { } It 'should support the "name" attribute' { - details -name MyGroup | Should -BeExactly '
' + details -Name MyGroup | Should -BeExactly '
' } It 'should support the "open" attribute' { diff --git a/test/Elements/New-EmbedElement.Tests.ps1 b/test/Elements/New-EmbedElement.Tests.ps1 index d3db4a1..c5eb2a8 100644 --- a/test/Elements/New-EmbedElement.Tests.ps1 +++ b/test/Elements/New-EmbedElement.Tests.ps1 @@ -8,6 +8,6 @@ Describe "New-EmbedElement" { } It 'should support the "src" and "type" attributes' { - embed -src Image.jpg -type image/jpeg | Should -BeIn '', '' + embed -Src Image.jpg -Type image/jpeg | Should -BeIn '', '' } } diff --git a/test/Elements/New-FormElement.Tests.ps1 b/test/Elements/New-FormElement.Tests.ps1 index eab1976..b3c0f5b 100644 --- a/test/Elements/New-FormElement.Tests.ps1 +++ b/test/Elements/New-FormElement.Tests.ps1 @@ -24,7 +24,7 @@ Describe "New-FormElement" { } It "should allow inner content" { - form (button OK -type submit) | Should -BeExactly '
' - form (input -name UserName) | Should -BeExactly '
' + form (button OK -Type submit) | Should -BeExactly '
' + form (input -Name UserName) | Should -BeExactly '
' } } diff --git a/test/Elements/New-IframeElement.Tests.ps1 b/test/Elements/New-IframeElement.Tests.ps1 index d5fa52c..616d5e4 100644 --- a/test/Elements/New-IframeElement.Tests.ps1 +++ b/test/Elements/New-IframeElement.Tests.ps1 @@ -8,16 +8,16 @@ Describe "New-IframeElement" { } It 'should support the "height" and "width" attributes' { - iframe -src Index.php -height 200 | Should -BeIn '', '' - iframe -src Index.php -width 460 | Should -BeIn '', '' + iframe -Src Index.php -Height 200 | Should -BeIn '', '' + iframe -Src Index.php -Width 460 | Should -BeIn '', '' } It 'should support the "loading" attribute' -ForEach eager, lazy { - iframe -src Index.php -loading $_ | Should -BeIn "", "" + iframe -Src Index.php -loading $_ | Should -BeIn "", "" } It 'should support the "sandbox" attribute' { $expected = '', '' - iframe -src Index.php -sandbox allow-downloads, allow-popups | Should -BeIn $expected + iframe -Src Index.php -sandbox allow-downloads, allow-popups | Should -BeIn $expected } } diff --git a/test/Elements/New-ImgElement.Tests.ps1 b/test/Elements/New-ImgElement.Tests.ps1 index 15a653f..382b563 100644 --- a/test/Elements/New-ImgElement.Tests.ps1 +++ b/test/Elements/New-ImgElement.Tests.ps1 @@ -12,22 +12,22 @@ Describe "New-ImgElement" { @{ Src = "Assets/Icon.gif"; Alt = "" } @{ Src = "Assets/Picture.jpg"; Alt = "A label describing the image." } ) { - $img = img -src $src -alt $alt + $img = img -Src $src -Alt $alt if ($null -eq $alt) { $img | Should -BeExactly "" } else { $img | Should -BeIn "", "" } } It 'should support the "ismap" and "usemap" attributes' { - img -src Image.webp -ismap | Should -BeIn '', '' - img -src Image.webp -usemap my-map | Should -BeIn '', '' + img -Src Image.webp -ismap | Should -BeIn '', '' + img -Src Image.webp -usemap my-map | Should -BeIn '', '' } It 'should support the "height" and "width" attributes' { - img -src Image.webp -height 200 | Should -BeIn '', '' - img -src Image.webp -width 460 | Should -BeIn '', '' + img -Src Image.webp -Height 200 | Should -BeIn '', '' + img -Src Image.webp -Width 460 | Should -BeIn '', '' } It 'should support the "loading" attribute' -ForEach eager, lazy { - img -src Image.webp -loading $_ | Should -BeIn "", "" + img -Src Image.webp -loading $_ | Should -BeIn "", "" } } diff --git a/test/Elements/New-InputElement.Tests.ps1 b/test/Elements/New-InputElement.Tests.ps1 index c8b154a..0ebc764 100644 --- a/test/Elements/New-InputElement.Tests.ps1 +++ b/test/Elements/New-InputElement.Tests.ps1 @@ -63,6 +63,6 @@ Describe "New-InputElement" { @{ Type = "submit"; Value = "OK" } ) { $expected = "", "" - input -type $type -value $value | Should -BeIn $expected + input -Type $type -value $value | Should -BeIn $expected } } diff --git a/test/Elements/New-LinkElement.Tests.ps1 b/test/Elements/New-LinkElement.Tests.ps1 index 9b1e087..f68a969 100644 --- a/test/Elements/New-LinkElement.Tests.ps1 +++ b/test/Elements/New-LinkElement.Tests.ps1 @@ -8,17 +8,17 @@ Describe "New-LinkElement" { } It 'should support the "href" and "rel" attributes' { - link -rel icon -href /Favicon.ico | Should -BeExactly '' - link -rel stylesheet -href /Assets/Styles.css | Should -BeExactly '' + link -Rel icon -Href /Favicon.ico | Should -BeExactly '' + link -Rel stylesheet -Href /Assets/Styles.css | Should -BeExactly '' } It 'should support the "media" attribute' { - link -rel alternate, stylesheet -href Styles.css -media print | Should -BeExactly '' - link -rel stylesheet -href Styles.css -media "screen and (width >= 600px)" | Should -BeExactly '' + link -Rel alternate, stylesheet -Href Styles.css -media print | Should -BeExactly '' + link -Rel stylesheet -Href Styles.css -media "screen and (width >= 600px)" | Should -BeExactly '' } It 'should support the "sizes" attribute' { - link -rel icon -href Favicon.ico -sizes any | Should -BeExactly '' - link -rel icon -href Favicon.ico -sizes 320x200, 160x100 | Should -BeExactly '' + link -Rel icon -Href Favicon.ico -sizes any | Should -BeExactly '' + link -Rel icon -Href Favicon.ico -sizes 320x200, 160x100 | Should -BeExactly '' } } diff --git a/test/Elements/New-MapElement.Tests.ps1 b/test/Elements/New-MapElement.Tests.ps1 index 3e4ce1a..d9e6b45 100644 --- a/test/Elements/New-MapElement.Tests.ps1 +++ b/test/Elements/New-MapElement.Tests.ps1 @@ -8,6 +8,6 @@ Describe "New-MapElement" { } It 'should support the "name" attribute' { - map -name MyMap | Should -BeExactly '' + map -Name MyMap | Should -BeExactly '' } } diff --git a/test/Elements/New-MetaElement.Tests.ps1 b/test/Elements/New-MetaElement.Tests.ps1 index b3511ef..30efff8 100644 --- a/test/Elements/New-MetaElement.Tests.ps1 +++ b/test/Elements/New-MetaElement.Tests.ps1 @@ -8,20 +8,20 @@ Describe "New-MetaElement" { } It 'should support the "charset" attribute' -ForEach "iso-8859-1", "utf-8" { - meta -charset $_ | Should -BeExactly "" + meta -Charset $_ | Should -BeExactly "" } It 'should support the "http-equiv" and "content" attributes' -ForEach @( @{ HttpEquiv = "content-type"; Content = "text/html; charset=utf-8" } @{ HttpEquiv = "refresh"; Content = 300 } ) { - meta -httpEquiv $httpEquiv -content $content | Should -BeExactly "" + meta -httpEquiv $httpEquiv -Content $content | Should -BeExactly "" } It 'should support the "name" and "content" attributes' -ForEach @( @{ Name = "application-name"; Content = "Belin.Html" } @{ Name = "color-scheme"; Content = "light dark" } ) { - meta -name $name -content $content | Should -BeExactly "" + meta -Name $name -Content $content | Should -BeExactly "" } } diff --git a/test/Elements/New-ObjectElement.Tests.ps1 b/test/Elements/New-ObjectElement.Tests.ps1 index 5bad26b..f4461e6 100644 --- a/test/Elements/New-ObjectElement.Tests.ps1 +++ b/test/Elements/New-ObjectElement.Tests.ps1 @@ -8,6 +8,6 @@ Describe "New-ObjectElement" { } It 'should support the "data" and "type" attributes' { - object -data Image.jpg -type image/jpeg | Should -BeIn '', '' + object -Data Image.jpg -Type image/jpeg | Should -BeIn '', '' } } diff --git a/test/Elements/New-OlElement.Tests.ps1 b/test/Elements/New-OlElement.Tests.ps1 index a101e51..9a3d1cc 100644 --- a/test/Elements/New-OlElement.Tests.ps1 +++ b/test/Elements/New-OlElement.Tests.ps1 @@ -12,6 +12,6 @@ Describe "New-OlElement" { } It 'should support the "type" attribute' -ForEach 1, A, a, I, i { - ol -type $_ | Should -BeExactly "
    " + ol -Type $_ | Should -BeExactly "
      " } } diff --git a/test/Elements/New-ScriptElement.Tests.ps1 b/test/Elements/New-ScriptElement.Tests.ps1 index 0c49839..a01cba4 100644 --- a/test/Elements/New-ScriptElement.Tests.ps1 +++ b/test/Elements/New-ScriptElement.Tests.ps1 @@ -11,20 +11,20 @@ Describe "New-ScriptElement" { @{ Src = "Scripts.js"; Type = "module" } @{ Src = "Scripts._hs"; Type = "text/hyperscript" } ) { - script -src $src -type $type | Should -BeExactly "" + script -Src $src -Type $type | Should -BeExactly "" } It 'should support the "async" and "defer" attributes' -ForEach @( @{ Async = $true; Defer = $false } @{ Async = $false; Defer = $true } ) { - script -src Scripts.js -async:$async -defer:$defer | Should -BeExactly ($async ? '' : '') + script -Src Scripts.js -async:$async -defer:$defer | Should -BeExactly ($async ? '' : '') } It "should allow inner content" -ForEach @( @{ Content = "alert('Hello World!');"; Type = "" } @{ Content = "on click call alert('Hello World!')"; Type = "text/hyperscript" } ) { - script $content -type $type | Should -BeExactly ($type ? "" : "") + script $content -Type $type | Should -BeExactly ($type ? "" : "") } } diff --git a/test/Elements/New-SlotElement.Tests.ps1 b/test/Elements/New-SlotElement.Tests.ps1 index d8fce58..6d22f5d 100644 --- a/test/Elements/New-SlotElement.Tests.ps1 +++ b/test/Elements/New-SlotElement.Tests.ps1 @@ -8,6 +8,6 @@ Describe "New-SlotElement" { } It 'should support the "name" attribute' { - slot -name MyMap | Should -BeExactly '' + slot -Name MyMap | Should -BeExactly '' } } diff --git a/test/Elements/New-SourceElement.Tests.ps1 b/test/Elements/New-SourceElement.Tests.ps1 index 719e6f5..a833e90 100644 --- a/test/Elements/New-SourceElement.Tests.ps1 +++ b/test/Elements/New-SourceElement.Tests.ps1 @@ -8,7 +8,7 @@ Describe "New-SourceElement" { } It 'should support the "src" and "type" attributes' { - source -src Video.webm -type video/webm | Should -BeIn '', '' + source -Src Video.webm -Type video/webm | Should -BeIn '', '' } It 'should support the "srcset" and "media" attributes' { diff --git a/test/Elements/New-TemplateElement.Tests.ps1 b/test/Elements/New-TemplateElement.Tests.ps1 index b22dda4..3b8f003 100644 --- a/test/Elements/New-TemplateElement.Tests.ps1 +++ b/test/Elements/New-TemplateElement.Tests.ps1 @@ -25,6 +25,6 @@ Describe "New-TemplateElement" { It "should allow inner content" { template (b "Hello World!") | Should -BeExactly "" - template (button OK -type submit) | Should -BeExactly '' + template (button OK -Type submit) | Should -BeExactly '' } } diff --git a/test/Elements/New-TrackElement.Tests.ps1 b/test/Elements/New-TrackElement.Tests.ps1 index 01a8833..1e316ea 100644 --- a/test/Elements/New-TrackElement.Tests.ps1 +++ b/test/Elements/New-TrackElement.Tests.ps1 @@ -8,10 +8,10 @@ Describe "New-TrackElement" { } It 'should support the "default" attribute' { - track -src Subtitles.vtt -default | Should -BeIn '', '' + track -Src Subtitles.vtt -default | Should -BeIn '', '' } It 'should support the "kind" attribute' -ForEach captions, chapters, descriptions, metadata, subtitles { - track -src Subtitles.vtt -kind $_ | Should -BeIn "", "" + track -Src Subtitles.vtt -kind $_ | Should -BeIn "", "" } } diff --git a/test/Elements/New-VideoElement.Tests.ps1 b/test/Elements/New-VideoElement.Tests.ps1 index 30f4edb..1dc69a7 100644 --- a/test/Elements/New-VideoElement.Tests.ps1 +++ b/test/Elements/New-VideoElement.Tests.ps1 @@ -23,6 +23,6 @@ Describe "New-VideoElement" { } It 'should support the "height" and "width" attributes' { - video -width 460 -height 200 | Should -BeIn '', '' + video -Width 460 -Height 200 | Should -BeIn '', '' } } diff --git a/test/New-CustomElement.Tests.ps1 b/test/New-CustomElement.Tests.ps1 index b190bf2..2f4a49b 100644 --- a/test/New-CustomElement.Tests.ps1 +++ b/test/New-CustomElement.Tests.ps1 @@ -11,45 +11,41 @@ Describe "New-CustomElement" { tag my-element | Should -BeExactly "" } - It "should handle void elements" { - tag my-element -Void | Should -BeExactly "" - } - It 'should handle the "id" attribute' { - tag my-element -id foo | Should -BeExactly '' + tag my-element -Id foo | Should -BeExactly '' } It 'should handle the "class" attribute' { - tag my-element -class btn, btn-danger | Should -BeExactly '' - tag my-element -class "btn btn-info", btn-sm | Should -BeExactly '' + tag my-element -Class btn, btn-danger | Should -BeExactly '' + tag my-element -Class "btn btn-info", btn-sm | Should -BeExactly '' } It 'should handle the "style" attribute' { $expected = '' - tag my-element -style ([ordered]@{ FontFamily = '"Segoe UI"'; FontSize = "1rem" }) | Should -BeExactly $expected + tag my-element -Style ([ordered]@{ FontFamily = '"Segoe UI"'; FontSize = "1rem" }) | Should -BeExactly $expected } It 'should handle the "tabindex" attribute' -ForEach -1, 0 { - tag my-element -tabindex $_ | Should -BeExactly "" + tag my-element -TabIndex $_ | Should -BeExactly "" } It 'should handle the "title" attribute' -ForEach "", 'A "custom" label.' { - tag my-element -title $_ | Should -BeExactly ($_ ? '' : "") + tag my-element -Title $_ | Should -BeExactly ($_ ? '' : "") } It "should handle custom attributes" { $expected = '', '' - tag my-element -attributes @{ "data-foo" = '"bar"'; disabled = $false; required = $true } -Void | Should -BeIn $expected + tag my-element -Attributes @{ "data-foo" = '"bar"'; disabled = $false; required = $true } -Void | Should -BeIn $expected } It "should handle data attributes" { $expected = '', '' - tag my-element -dataset @{ BsToggle = "tooltip"; PushUrl = $true } | Should -BeIn $expected + tag my-element -Data @{ BsToggle = "tooltip"; PushUrl = $true } | Should -BeIn $expected } It "should handle event handler attributes" { $expected = '', '' - tag my-element -on @{ Click = "submit(event)"; ContextMenu = "showMenu()" } | Should -BeIn $expected + tag my-element -On @{ Click = "submit(event)"; ContextMenu = "showMenu()" } | Should -BeIn $expected } It "should handle the inner content" { diff --git a/test/New-DocumentType.Tests.ps1 b/test/New-DocumentType.Tests.ps1 index 383a923..91f4a08 100644 --- a/test/New-DocumentType.Tests.ps1 +++ b/test/New-DocumentType.Tests.ps1 @@ -8,7 +8,7 @@ Describe "New-DocumentType" { } It "should return a document type declaration" -ForEach @( - @{ Value = ""; Expected = "" } + @{ Value = $null; Expected = "" } @{ Value = 'html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"'; Expected = '' } @{ Value = 'html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"'; Expected = ''} ) { diff --git a/test/New-Element.Tests.ps1 b/test/New-Element.Tests.ps1 deleted file mode 100644 index 10f83a4..0000000 --- a/test/New-Element.Tests.ps1 +++ /dev/null @@ -1,80 +0,0 @@ -<# -.SYNOPSIS - Tests the features of the `Write-Element` cmdlet. -#> -Describe "Write-Element" { - BeforeAll { - Import-Module "$PSScriptRoot/../Html.psd1" - } - - It "should create an HTML element from the specified tag name" -ForEach @( - @{ Tag = "b"; Expected = "" } - @{ Tag = "html"; Expected = "" } - ) { - & $tag | Should -BeExactly $expected - } - - It "should handle void elements" -ForEach @( - @{ Tag = "br"; Expected = "
      " } - @{ Tag = "input"; Expected = "" } - ) { - & $tag | Should -BeExactly $expected - } - - It 'should handle the "class" attribute' { - body -class btn, btn-danger | Should -BeExactly '' - body -class "btn btn-info", btn-sm | Should -BeExactly '' - } - - It 'should support the "dir" attribute' -ForEach auto, ltr, rtl { - html -dir $_ | Should -BeExactly "" - } - - It 'should handle the "id" attribute' { - article -id foo | Should -BeExactly '
      ' - } - - It 'should support the "lang" attribute' -ForEach "fr-FR", "en-US" { - html -lang $_ | Should -BeExactly "" - } - - It 'should handle the "style" attribute' { - $expected = '' - code -style ([ordered]@{ FontFamily = '"Segoe UI"'; FontSize = "1rem" }) | Should -BeExactly $expected - } - - It 'should handle the "tabindex" attribute' -ForEach -1, 0 { - div -tabindex $_ | Should -BeExactly "
      " - } - - It 'should handle the "title" attribute' -ForEach "", 'A "custom" label.' { - div -title $_ | Should -BeExactly ($_ ? '
      ' : "
      ") - } - - It "should handle custom attributes" { - $expected = '', '' - input -attributes @{ "data-foo" = '"bar"'; disabled = $false; required = $true } | Should -BeIn $expected - } - - It "should handle data attributes" { - $expected = '', '' - button -dataset @{ BsToggle = "tooltip"; PushUrl = $true } | Should -BeIn $expected - } - - It "should handle event handler attributes" { - $expected = '', '' - button -on @{ Click = "submit(event)"; ContextMenu = "showMenu()" } | Should -BeIn $expected - } - - It "should handle switch parameters in attribute values" { - input -attributes @{ disabled = [switch] $false; required = [switch] $true } | Should -BeExactly "" - } - - It "should handle the inner content" { - $expected = "
      Foo > Bar Baz < Qux
      " - main { div { "Foo > Bar"; " "; span "Baz < Qux" } } | Should -BeExactly $expected - - $expected = '' - head { meta -charset utf-8 } | Should -BeExactly $expected - } -} diff --git a/test/Use-Layout.Tests.ps1 b/test/Use-Layout.Tests.ps1 index bdfbde2..a39bac7 100644 --- a/test/Use-Layout.Tests.ps1 +++ b/test/Use-Layout.Tests.ps1 @@ -9,7 +9,7 @@ Describe "Use-Layout" { It "should render the specified HTML content inside the given layout" { $data = @{ AppName = "My Application"; Title = "The headline"; Year = 2025 } - $html = layout "$PSScriptRoot/../res/Layout.ps1" (& "$PSScriptRoot/../res/Content.ps1" $data) -data $data + $html = layout "$PSScriptRoot/../res/Layout.ps1" (& "$PSScriptRoot/../res/Content.ps1" $data) -Data $data $html | Should -BeLikeExactly '*My Application*' $html | Should -BeLikeExactly '*
      *
      My Application
      *
      *' $html | Should -BeLikeExactly '*

      The headline

      Welcome to my website!
      *' diff --git a/test/Write-Element.Tests.ps1 b/test/Write-Element.Tests.ps1 index 10f83a4..ea9491f 100644 --- a/test/Write-Element.Tests.ps1 +++ b/test/Write-Element.Tests.ps1 @@ -22,52 +22,52 @@ Describe "Write-Element" { } It 'should handle the "class" attribute' { - body -class btn, btn-danger | Should -BeExactly '' - body -class "btn btn-info", btn-sm | Should -BeExactly '' + body -Class btn, btn-danger | Should -BeExactly '' + body -Class "btn btn-info", btn-sm | Should -BeExactly '' } It 'should support the "dir" attribute' -ForEach auto, ltr, rtl { - html -dir $_ | Should -BeExactly "" + html -Dir $_ | Should -BeExactly "" } It 'should handle the "id" attribute' { - article -id foo | Should -BeExactly '
      ' + article -Id foo | Should -BeExactly '
      ' } It 'should support the "lang" attribute' -ForEach "fr-FR", "en-US" { - html -lang $_ | Should -BeExactly "" + html -Lang $_ | Should -BeExactly "" } It 'should handle the "style" attribute' { $expected = '' - code -style ([ordered]@{ FontFamily = '"Segoe UI"'; FontSize = "1rem" }) | Should -BeExactly $expected + code -Style ([ordered]@{ FontFamily = '"Segoe UI"'; FontSize = "1rem" }) | Should -BeExactly $expected } It 'should handle the "tabindex" attribute' -ForEach -1, 0 { - div -tabindex $_ | Should -BeExactly "
      " + div -TabIndex $_ | Should -BeExactly "
      " } It 'should handle the "title" attribute' -ForEach "", 'A "custom" label.' { - div -title $_ | Should -BeExactly ($_ ? '
      ' : "
      ") + div -Title $_ | Should -BeExactly ($_ ? '
      ' : "
      ") } It "should handle custom attributes" { $expected = '', '' - input -attributes @{ "data-foo" = '"bar"'; disabled = $false; required = $true } | Should -BeIn $expected + input -Attributes @{ "data-foo" = '"bar"'; disabled = $false; required = $true } | Should -BeIn $expected } It "should handle data attributes" { $expected = '', '' - button -dataset @{ BsToggle = "tooltip"; PushUrl = $true } | Should -BeIn $expected + button -Data @{ BsToggle = "tooltip"; PushUrl = $true } | Should -BeIn $expected } It "should handle event handler attributes" { $expected = '', '' - button -on @{ Click = "submit(event)"; ContextMenu = "showMenu()" } | Should -BeIn $expected + button -On @{ Click = "submit(event)"; ContextMenu = "showMenu()" } | Should -BeIn $expected } It "should handle switch parameters in attribute values" { - input -attributes @{ disabled = [switch] $false; required = [switch] $true } | Should -BeExactly "" + input -Attributes @{ disabled = [switch] $false; required = [switch] $true } | Should -BeExactly "" } It "should handle the inner content" { @@ -75,6 +75,6 @@ Describe "Write-Element" { main { div { "Foo > Bar"; " "; span "Baz < Qux" } } | Should -BeExactly $expected $expected = '' - head { meta -charset utf-8 } | Should -BeExactly $expected + head { meta -Charset utf-8 } | Should -BeExactly $expected } } From 5259701459ff12a63dd91b18e3a4f28ef1ce9193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sun, 26 Apr 2026 19:14:15 +0200 Subject: [PATCH 23/23] Port the `New-HtmlAreaElement` cmdlet --- Html.psd1 | 3 + src/Elements/New-AElement.psm1 | 8 +- src/Elements/New-AreaElement.psm1 | 109 +++++++++++------------- src/Elements/New-AudioElement.psm1 | 16 ++-- src/Elements/New-BaseElement.psm1 | 4 +- src/Elements/New-BlockquoteElement.psm1 | 2 +- src/Elements/New-ButtonElement.psm1 | 28 +++--- src/Elements/New-CanvasElement.psm1 | 4 +- src/Elements/New-ColElement.psm1 | 2 +- src/Elements/New-ColGroupElement.psm1 | 2 +- src/Elements/New-DataElement.psm1 | 2 +- src/Elements/New-DelElement.psm1 | 4 +- src/Elements/New-DetailsElement.psm1 | 4 +- src/Elements/New-DialogElement.psm1 | 4 +- src/Elements/New-EmbedElement.psm1 | 8 +- src/Elements/New-FieldsetElement.psm1 | 6 +- src/Elements/New-FormElement.psm1 | 16 ++-- src/Elements/New-IframeElement.psm1 | 16 ++-- src/Elements/New-ImgElement.psm1 | 18 ++-- src/Elements/New-InputElement.psm1 | 64 +++++++------- src/Elements/New-InsElement.psm1 | 4 +- src/Elements/New-LabelElement.psm1 | 2 +- src/Elements/New-LiElement.psm1 | 2 +- src/Elements/New-LinkElement.psm1 | 16 ++-- src/Elements/New-MapElement.psm1 | 2 +- src/Elements/New-MetaElement.psm1 | 10 +-- src/Elements/New-MeterElement.psm1 | 12 +-- src/Elements/New-ObjectElement.psm1 | 12 +-- src/Elements/New-OlElement.psm1 | 6 +- src/Elements/New-OptgroupElement.psm1 | 4 +- src/Elements/New-OptionElement.psm1 | 8 +- src/Elements/New-OutputElement.psm1 | 6 +- src/Elements/New-ProgressElement.psm1 | 4 +- src/Elements/New-QElement.psm1 | 2 +- src/Elements/New-ScriptElement.psm1 | 12 +-- src/Elements/New-SelectElement.psm1 | 14 +-- src/Elements/New-SlotElement.psm1 | 2 +- src/Elements/New-SourceElement.psm1 | 14 +-- src/Elements/New-StyleElement.psm1 | 2 +- src/Elements/New-TdElement.psm1 | 6 +- src/Elements/New-TemplateElement.psm1 | 8 +- src/Elements/New-TextareaElement.psm1 | 28 +++--- src/Elements/New-ThElement.psm1 | 10 +-- src/Elements/New-TimeElement.psm1 | 2 +- src/Elements/New-TrackElement.psm1 | 10 +-- src/Elements/New-VideoElement.psm1 | 26 +++--- test/Elements/New-AreaElement.Tests.ps1 | 2 +- 47 files changed, 268 insertions(+), 278 deletions(-) diff --git a/Html.psd1 b/Html.psd1 index d4408f7..3b3a47f 100644 --- a/Html.psd1 +++ b/Html.psd1 @@ -15,6 +15,7 @@ AliasesToExport = @( "doctype" "a" + "area" "tag" ) @@ -22,10 +23,12 @@ "New-HtmlAElement" "New-HtmlDocumentType" "New-HtmlCustomElement" + "New-HtmlAreaElement" ) NestedModules = @( "src/Elements/New-AElement.psm1" + "src/Elements/New-AreaElement.psm1" "src/New-DocumentType.psm1" "src/New-CustomElement.psm1" ) diff --git a/src/Elements/New-AElement.psm1 b/src/Elements/New-AElement.psm1 index 1492b7d..81f3730 100644 --- a/src/Elements/New-AElement.psm1 +++ b/src/Elements/New-AElement.psm1 @@ -13,6 +13,10 @@ function New-HtmlAElement { [CmdletBinding()] [OutputType([string])] param ( + # The URL that the hyperlink points to. + [Parameter(Mandatory)] + [uri] $Href, + # The inner HTML of the element. [Parameter(Position = 0, ValueFromPipeline)] [object] $Content, @@ -23,10 +27,6 @@ function New-HtmlAElement { # The suggested filename when the browser treats the linked URL as a download. [string] $Download, - # The URL that the hyperlink points to. - [Parameter(Mandatory)] - [uri] $Href, - # A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. [uri[]] $Ping = @(), diff --git a/src/Elements/New-AreaElement.psm1 b/src/Elements/New-AreaElement.psm1 index 74cfd1e..a5c8449 100644 --- a/src/Elements/New-AreaElement.psm1 +++ b/src/Elements/New-AreaElement.psm1 @@ -1,81 +1,68 @@ -using module ../New-Element.psm1 +using module ../Write-Element.psm1 <# .SYNOPSIS Creates a new `area` element. +.INPUTS + The inner HTML of the `area` element. +.OUTPUTS + The newly created `area` element. #> -[Cmdlet(VerbsCommon.New, "HtmlAreaElement"), Alias("area"), OutputType(typeof(string))] -function New-HtmlAreaElement: NewElementCommand("area", isVoid: true) { +function New-HtmlAreaElement { + [Alias("area")] + [CmdletBinding()] + [OutputType([string])] + param ( + # The hyperlink target for the area. + [Parameter(Mandatory)] + [uri] $Href, - <# - .SYNOPSIS - A text to display on browsers that do not display images. - #> - [string] $Alt + # The inner HTML of the element. + [Parameter(Position = 0, ValueFromPipeline)] + [object] $Content, - <# - .SYNOPSIS - The browsing context to show the results of navigation. - #> - [ValidateCount(3, int.MaxValue)] - double[]? Coords + # The custom attributes to render. + [hashtable] $Attributes = @{}, - <# - .SYNOPSIS - The suggested filename when the browser treats the linked URL as a download. - #> - [string] $Download + # A text to display on browsers that do not display images. + [string] $Alt, - <# - .SYNOPSIS - The hyperlink target for the area. - #> - [Parameter(Mandatory)] - [uri] $Href + # The browsing context to show the results of navigation. + [ValidateCount(3, [int]::MaxValue)] + [double[]] $Coords, - <# - .SYNOPSIS - A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. - #> - [uri[]] $Ping = @(), + # The suggested filename when the browser treats the linked URL as a download. + [string] $Download, - <# - .SYNOPSIS - The relationship of the linked URL. - #> - [string[]] $Rel = @(), + # A list of URLs. When the link is followed, the browser will send `POST` requests with the body `PING` to the URLs. + [uri[]] $Ping = @(), - <# - .SYNOPSIS - The browsing context to show the results of navigation. - #> + # The relationship of the linked URL. + [string[]] $Rel = @(), + + # The browsing context to show the results of navigation. [ValidateSet("circle", "default", "poly", "rect")] - [string] $Shape + [string] $Shape, - <# - .SYNOPSIS - The browsing context to show the results of navigation. - #> - [string] $Target + # The browsing context to show the results of navigation. + [string] $Target + ) - <# - .SYNOPSIS - Populates the specified attribute collection with the element attributes. - #> - /// The attribute collection to populate. - protected override void RenderAttributes(IDictionary attributes) { - base.RenderAttributes(attributes); - attributes["href"] = Href.ToString(); + process { + $attributesToRender = $Attributes.Clone() + $attributesToRender.href = $Href + if ($Alt) { $attributesToRender.alt = $Alt } + if ($Download) { $attributesToRender.download = $Download } + if ($Ping) { $attributesToRender.ping = ($Ping -join " ").Trim() } + if ($Rel) { $attributesToRender.rel = ($Rel -join " ").Trim() } + if ($Target) { $attributesToRender.target = $Target } - if (Shape is not null) { - attributes["shape"] = Shape; - if (Coords is not null && Shape != "default") attributes["coords"] = string.Join(',', Coords.Select(number => number.ToString(CultureInfo.InvariantCulture))); + if ($Shape) { + $attributesToRender.shape = $Shape + if ($Coords -and ($Shape -ne "default")) { $attributesToRender.coords = $Coords.ForEach{ [string] $_ } -join "," } } - if (Alt is not null) attributes["alt"] = Alt; - if (-not [string]::IsNullOrWhiteSpace(Download)) attributes["download"] = Download; - if (Ping.Length > 0) attributes["ping"] = string.Join(' ', Ping.Select(url => url.ToString())).Trim(); - if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); - if (-not [string]::IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + $MyInvocation.MyCommand.Parameters.Keys.ForEach{ $PSBoundParameters.Remove($_) | Out-Null } + Write-HtmlElement -TagName area -Attributes $attributesToRender -Content $Content -Void @PSBoundParameters } } diff --git a/src/Elements/New-AudioElement.psm1 b/src/Elements/New-AudioElement.psm1 index 7beee0c..afa5c0d 100644 --- a/src/Elements/New-AudioElement.psm1 +++ b/src/Elements/New-AudioElement.psm1 @@ -64,13 +64,13 @@ function New-HtmlAudioElement: NewElementCommand("audio", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (AutoPlay) attributes["autoplay"] = true; - if (Controls) attributes["controls"] = true; - if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (DisableRemotePlayback) attributes["disableremoteplayback"] = true; - if (Loop) attributes["loop"] = true; - if (Muted) attributes["muted"] = true; - if (Preload is not null) attributes["preload"] = Preload; - if (Src is not null) attributes["src"] = Src.ToString(); + if (AutoPlay) $attributesToRender.autoplay"] = true; + if (Controls) $attributesToRender.controls"] = true; + if (CrossOrigin is not null) $attributesToRender.crossorigin"] = CrossOrigin; + if (DisableRemotePlayback) $attributesToRender.disableremoteplayback"] = true; + if (Loop) $attributesToRender.loop"] = true; + if (Muted) $attributesToRender.muted"] = true; + if (Preload is not null) $attributesToRender.preload"] = Preload; + if (Src is not null) $attributesToRender.src"] = Src.ToString(); } } diff --git a/src/Elements/New-BaseElement.psm1 b/src/Elements/New-BaseElement.psm1 index b72209b..44457b9 100644 --- a/src/Elements/New-BaseElement.psm1 +++ b/src/Elements/New-BaseElement.psm1 @@ -27,7 +27,7 @@ function New-HtmlBaseElement: NewElementCommand("base", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["href"] = Href.ToString(); - if (-not [string]::IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + $attributesToRender.href"] = Href.ToString(); + if ($Target) { $attributesToRender.target"] = Target; } } diff --git a/src/Elements/New-BlockquoteElement.psm1 b/src/Elements/New-BlockquoteElement.psm1 index 51bbbeb..86149c6 100644 --- a/src/Elements/New-BlockquoteElement.psm1 +++ b/src/Elements/New-BlockquoteElement.psm1 @@ -20,6 +20,6 @@ function New-HtmlBlockquoteElement: NewElementCommand("blockquote", isVoid: fals /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Cite is not null) attributes["cite"] = Cite.ToString(); + if (Cite is not null) $attributesToRender.cite"] = Cite.ToString(); } } diff --git a/src/Elements/New-ButtonElement.psm1 b/src/Elements/New-ButtonElement.psm1 index 12011ff..98edd2d 100644 --- a/src/Elements/New-ButtonElement.psm1 +++ b/src/Elements/New-ButtonElement.psm1 @@ -103,19 +103,19 @@ function New-HtmlButtonElement: NewElementCommand("button", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(Command)) attributes["command"] = Command; - if (-not [string]::IsNullOrWhiteSpace(CommandFor)) attributes["commandfor"] = CommandFor; - if (Disabled) attributes["disabled"] = true; - if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (FormAction is not null) attributes["formaction"] = FormAction.ToString(); - if (FormEnctype is not null) attributes["formenctype"] = FormEnctype; - if (FormMethod is not null) attributes["formmethod"] = FormMethod; - if (FormNoValidate) attributes["formnovalidate"] = true; - if (-not [string]::IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (-not [string]::IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; - if (PopoverTargetAction is not null) attributes["popovertargetaction"] = PopoverTargetAction; - if (Type is not null) attributes["type"] = Type; - if (Value is not null) attributes["value"] = Value; + if ($Command) { $attributesToRender.command"] = Command; + if ($CommandFor) { $attributesToRender.commandfor"] = CommandFor; + if (Disabled) $attributesToRender.disabled"] = true; + if ($Form) { $attributesToRender.form"] = Form; + if (FormAction is not null) $attributesToRender.formaction"] = FormAction.ToString(); + if (FormEnctype is not null) $attributesToRender.formenctype"] = FormEnctype; + if (FormMethod is not null) $attributesToRender.formmethod"] = FormMethod; + if (FormNoValidate) $attributesToRender.formnovalidate"] = true; + if ($FormTarget) { $attributesToRender.formtarget"] = FormTarget; + if ($Name) { $attributesToRender.name"] = Name; + if ($PopoverTarget) { $attributesToRender.popovertarget"] = PopoverTarget; + if (PopoverTargetAction is not null) $attributesToRender.popovertargetaction"] = PopoverTargetAction; + if (Type is not null) $attributesToRender.type"] = Type; + if (Value is not null) $attributesToRender.value"] = Value; } } diff --git a/src/Elements/New-CanvasElement.psm1 b/src/Elements/New-CanvasElement.psm1 index 8b99214..fd679cc 100644 --- a/src/Elements/New-CanvasElement.psm1 +++ b/src/Elements/New-CanvasElement.psm1 @@ -28,7 +28,7 @@ function New-HtmlCanvasElement: NewElementCommand("canvas", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Height >= 0) attributes["height"] = Height - if (Width >= 0) attributes["width"] = Width + if (Height >= 0) $attributesToRender.height"] = Height + if (Width >= 0) $attributesToRender.width"] = Width } } diff --git a/src/Elements/New-ColElement.psm1 b/src/Elements/New-ColElement.psm1 index 4b32640..1657eb5 100644 --- a/src/Elements/New-ColElement.psm1 +++ b/src/Elements/New-ColElement.psm1 @@ -21,6 +21,6 @@ function New-HtmlColElement: NewElementCommand("col", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Span > 0) attributes["span"] = Span + if (Span > 0) $attributesToRender.span"] = Span } } diff --git a/src/Elements/New-ColGroupElement.psm1 b/src/Elements/New-ColGroupElement.psm1 index 18ac67c..959e79c 100644 --- a/src/Elements/New-ColGroupElement.psm1 +++ b/src/Elements/New-ColGroupElement.psm1 @@ -21,6 +21,6 @@ function New-HtmlColgroupElement: NewElementCommand("colgroup", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Span > 0) attributes["span"] = Span + if (Span > 0) $attributesToRender.span"] = Span } } diff --git a/src/Elements/New-DataElement.psm1 b/src/Elements/New-DataElement.psm1 index 96350f1..d45b25d 100644 --- a/src/Elements/New-DataElement.psm1 +++ b/src/Elements/New-DataElement.psm1 @@ -21,6 +21,6 @@ function New-HtmlDataElement: NewElementCommand("data", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["value"] = Value; + $attributesToRender.value"] = Value; } } diff --git a/src/Elements/New-DelElement.psm1 b/src/Elements/New-DelElement.psm1 index 7a4b52a..9dd633b 100644 --- a/src/Elements/New-DelElement.psm1 +++ b/src/Elements/New-DelElement.psm1 @@ -26,11 +26,11 @@ function New-HtmlDelElement: NewElementCommand("del", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Cite is not null) attributes["cite"] = Cite.ToString(); + if (Cite is not null) $attributesToRender.cite"] = Cite.ToString(); if (DateTime is not null) { try { - attributes["datetime"] = (DateTime is PSObject psObject ? psObject.BaseObject : DateTime) switch { + $attributesToRender.datetime"] = (DateTime is PSObject psObject ? psObject.BaseObject : DateTime) switch { DateOnly value => value.ToString("o"), DateTime value => value.ToString("o"), _ => throw new NotSupportedException("The specified date/time value is not supported.") diff --git a/src/Elements/New-DetailsElement.psm1 b/src/Elements/New-DetailsElement.psm1 index 351f4c3..82863c0 100644 --- a/src/Elements/New-DetailsElement.psm1 +++ b/src/Elements/New-DetailsElement.psm1 @@ -26,7 +26,7 @@ function New-HtmlDetailsElement: NewElementCommand("details", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Open) attributes["open"] = true; + if ($Name) { $attributesToRender.name"] = Name; + if (Open) $attributesToRender.open"] = true; } } diff --git a/src/Elements/New-DialogElement.psm1 b/src/Elements/New-DialogElement.psm1 index ddd838d..241bd37 100644 --- a/src/Elements/New-DialogElement.psm1 +++ b/src/Elements/New-DialogElement.psm1 @@ -27,7 +27,7 @@ function New-HtmlDialogElement: NewElementCommand("dialog", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (ClosedBy is not null) attributes["closedby"] = ClosedBy; - if (Open) attributes["open"] = true; + if (ClosedBy is not null) $attributesToRender.closedby"] = ClosedBy; + if (Open) $attributesToRender.open"] = true; } } diff --git a/src/Elements/New-EmbedElement.psm1 b/src/Elements/New-EmbedElement.psm1 index 503c784..ea13c85 100644 --- a/src/Elements/New-EmbedElement.psm1 +++ b/src/Elements/New-EmbedElement.psm1 @@ -42,9 +42,9 @@ function New-HtmlEmbedElement: NewElementCommand("embed", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["src"] = Src.ToString(); - attributes["type"] = Type; - if (Height >= 0) attributes["height"] = Height - if (Width >= 0) attributes["width"] = Width + $attributesToRender.src"] = Src.ToString(); + $attributesToRender.type"] = Type; + if (Height >= 0) $attributesToRender.height"] = Height + if (Width >= 0) $attributesToRender.width"] = Width } } diff --git a/src/Elements/New-FieldsetElement.psm1 b/src/Elements/New-FieldsetElement.psm1 index 8a1ba9b..2eb8f0a 100644 --- a/src/Elements/New-FieldsetElement.psm1 +++ b/src/Elements/New-FieldsetElement.psm1 @@ -32,8 +32,8 @@ function New-HtmlFieldsetElement: NewElementCommand("fieldset", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Disabled) attributes["disabled"] = true; - if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (Disabled) $attributesToRender.disabled"] = true; + if ($Form) { $attributesToRender.form"] = Form; + if ($Name) { $attributesToRender.name"] = Name; } } diff --git a/src/Elements/New-FormElement.psm1 b/src/Elements/New-FormElement.psm1 index 7cad0d7..d4995dd 100644 --- a/src/Elements/New-FormElement.psm1 +++ b/src/Elements/New-FormElement.psm1 @@ -66,13 +66,13 @@ function New-HtmlFormElement: NewElementCommand("form", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Action is not null) attributes["action"] = Action.ToString(); - if (AutoComplete is not null) attributes["autocomplete"] = AutoComplete; - if (Enctype is not null) attributes["enctype"] = Enctype; - if (Method is not null) attributes["method"] = Method; - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (NoValidate) attributes["novalidate"] = true; - if (Rel.Length > 0) attributes["rel"] = string.Join(' ', Rel).Trim(); - if (-not [string]::IsNullOrWhiteSpace(Target)) attributes["target"] = Target; + if (Action is not null) $attributesToRender.action"] = Action.ToString(); + if (AutoComplete is not null) $attributesToRender.autocomplete"] = AutoComplete; + if (Enctype is not null) $attributesToRender.enctype"] = Enctype; + if (Method is not null) $attributesToRender.method"] = Method; + if ($Name) { $attributesToRender.name"] = Name; + if (NoValidate) $attributesToRender.novalidate"] = true; + if (Rel.Length > 0) $attributesToRender.rel"] = string.Join(' ', Rel).Trim(); + if ($Target) { $attributesToRender.target"] = Target; } } diff --git a/src/Elements/New-IframeElement.psm1 b/src/Elements/New-IframeElement.psm1 index 2439845..b8558b9 100644 --- a/src/Elements/New-IframeElement.psm1 +++ b/src/Elements/New-IframeElement.psm1 @@ -70,13 +70,13 @@ function New-HtmlIframeElement: NewElementCommand("iframe", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["src"] = Src.ToString(); - if (-not [string]::IsNullOrWhiteSpace(Allow)) attributes["allow"] = Allow; - if (Height >= 0) attributes["height"] = Height - if (Loading is not null) attributes["loading"] = Loading; - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (ReferrerPolicy is not null) attributes["referrerpolicy"] = ReferrerPolicy; - if (Sandbox.Length > 0) attributes["sandbox"] = string.Join(' ', Sandbox).Trim(); - if (Width >= 0) attributes["width"] = Width + $attributesToRender.src"] = Src.ToString(); + if ($Allow) { $attributesToRender.allow"] = Allow; + if (Height >= 0) $attributesToRender.height"] = Height + if (Loading is not null) $attributesToRender.loading"] = Loading; + if ($Name) { $attributesToRender.name"] = Name; + if (ReferrerPolicy is not null) $attributesToRender.referrerpolicy"] = ReferrerPolicy; + if (Sandbox.Length > 0) $attributesToRender.sandbox"] = string.Join(' ', Sandbox).Trim(); + if (Width >= 0) $attributesToRender.width"] = Width } } diff --git a/src/Elements/New-ImgElement.psm1 b/src/Elements/New-ImgElement.psm1 index 22dbd06..56e9de0 100644 --- a/src/Elements/New-ImgElement.psm1 +++ b/src/Elements/New-ImgElement.psm1 @@ -73,14 +73,14 @@ function New-HtmlImgElement: NewElementCommand("img", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["src"] = Src.ToString(); - if (Alt is not null) attributes["alt"] = Alt; - if (Height >= 0) attributes["height"] = Height - if (IsMap) attributes["ismap"] = true; - if (Loading is not null) attributes["loading"] = Loading; - if (Sizes.Length > 0) attributes["sizes"] = string.Join(", ", Sizes); - if (SrcSet.Length > 0) attributes["srcset"] = string.Join(", ", SrcSet); - if (-not [string]::IsNullOrWhiteSpace(UseMap)) attributes["usemap"] = UseMap.StartsWith('#') ? UseMap : $"#{UseMap}"; - if (Width >= 0) attributes["width"] = Width + $attributesToRender.src"] = Src.ToString(); + if (Alt is not null) $attributesToRender.alt"] = Alt; + if (Height >= 0) $attributesToRender.height"] = Height + if (IsMap) $attributesToRender.ismap"] = true; + if (Loading is not null) $attributesToRender.loading"] = Loading; + if (Sizes.Length > 0) $attributesToRender.sizes"] = string.Join(", ", Sizes); + if (SrcSet.Length > 0) $attributesToRender.srcset"] = string.Join(", ", SrcSet); + if ($UseMap) { $attributesToRender.usemap"] = UseMap.StartsWith('#') ? UseMap : $"#{UseMap}"; + if (Width >= 0) $attributesToRender.width"] = Width } } diff --git a/src/Elements/New-InputElement.psm1 b/src/Elements/New-InputElement.psm1 index b00957b..62a8579 100644 --- a/src/Elements/New-InputElement.psm1 +++ b/src/Elements/New-InputElement.psm1 @@ -241,37 +241,37 @@ function New-HtmlInputElement: NewElementCommand("input", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(Accept)) attributes["accept"] = Accept; - if (Alt is not null) attributes["alt"] = Alt; - if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); - if (Capture is not null) attributes["capture"] = Capture; - if (Checked) attributes["checked"] = true; - if (-not [string]::IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; - if (Disabled) attributes["disabled"] = true; - if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (FormAction is not null) attributes["formaction"] = FormAction.ToString(); - if (FormEnctype is not null) attributes["formenctype"] = FormEnctype; - if (FormMethod is not null) attributes["formmethod"] = FormMethod; - if (FormNoValidate) attributes["formnovalidate"] = true; - if (-not [string]::IsNullOrWhiteSpace(FormTarget)) attributes["formtarget"] = FormTarget; - if (Height >= 0) attributes["height"] = Height - if (-not [string]::IsNullOrWhiteSpace(List)) attributes["list"] = List; - if (-not [string]::IsNullOrWhiteSpace(Max)) attributes["max"] = Max; - if (MaxLength >= 0) attributes["maxlength"] = MaxLength - if (-not [string]::IsNullOrWhiteSpace(Min)) attributes["min"] = Min; - if (MinLength >= 0) attributes["minlength"] = MinLength - if (Multiple) attributes["multiple"] = true; - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Pattern is not null) attributes["pattern"] = Pattern.ToString().Replace(@"\", @"\\"); - if (-not [string]::IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; - if (-not [string]::IsNullOrWhiteSpace(PopoverTarget)) attributes["popovertarget"] = PopoverTarget; - if (PopoverTargetAction is not null) attributes["popovertargetaction"] = PopoverTargetAction; - if (ReadOnly) attributes["readonly"] = true; - if (Required) attributes["required"] = true; - if (Size > 0) attributes["size"] = Size - if (-not [string]::IsNullOrWhiteSpace(Step)) attributes["step"] = Step; - if (Type is not null) attributes["type"] = Type; - if (Value is not null) attributes["value"] = Value; - if (Width >= 0) attributes["width"] = Width + if ($Accept) { $attributesToRender.accept"] = Accept; + if (Alt is not null) $attributesToRender.alt"] = Alt; + if (AutoComplete.Length > 0) $attributesToRender.autocomplete"] = string.Join(' ', AutoComplete).Trim(); + if (Capture is not null) $attributesToRender.capture"] = Capture; + if (Checked) $attributesToRender.checked"] = true; + if ($DirName) { $attributesToRender.dirname"] = DirName; + if (Disabled) $attributesToRender.disabled"] = true; + if ($Form) { $attributesToRender.form"] = Form; + if (FormAction is not null) $attributesToRender.formaction"] = FormAction.ToString(); + if (FormEnctype is not null) $attributesToRender.formenctype"] = FormEnctype; + if (FormMethod is not null) $attributesToRender.formmethod"] = FormMethod; + if (FormNoValidate) $attributesToRender.formnovalidate"] = true; + if ($FormTarget) { $attributesToRender.formtarget"] = FormTarget; + if (Height >= 0) $attributesToRender.height"] = Height + if ($List) { $attributesToRender.list"] = List; + if ($Max) { $attributesToRender.max"] = Max; + if (MaxLength >= 0) $attributesToRender.maxlength"] = MaxLength + if ($Min) { $attributesToRender.min"] = Min; + if (MinLength >= 0) $attributesToRender.minlength"] = MinLength + if (Multiple) $attributesToRender.multiple"] = true; + if ($Name) { $attributesToRender.name"] = Name; + if (Pattern is not null) $attributesToRender.pattern"] = Pattern.ToString().Replace(@"\", @"\\"); + if ($Placeholder) { $attributesToRender.placeholder"] = Placeholder; + if ($PopoverTarget) { $attributesToRender.popovertarget"] = PopoverTarget; + if (PopoverTargetAction is not null) $attributesToRender.popovertargetaction"] = PopoverTargetAction; + if (ReadOnly) $attributesToRender.readonly"] = true; + if (Required) $attributesToRender.required"] = true; + if (Size > 0) $attributesToRender.size"] = Size + if ($Step) { $attributesToRender.step"] = Step; + if (Type is not null) $attributesToRender.type"] = Type; + if (Value is not null) $attributesToRender.value"] = Value; + if (Width >= 0) $attributesToRender.width"] = Width } } diff --git a/src/Elements/New-InsElement.psm1 b/src/Elements/New-InsElement.psm1 index 719e522..31e0ecc 100644 --- a/src/Elements/New-InsElement.psm1 +++ b/src/Elements/New-InsElement.psm1 @@ -26,11 +26,11 @@ function New-HtmlInsElement: NewElementCommand("ins", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Cite is not null) attributes["cite"] = Cite.ToString(); + if (Cite is not null) $attributesToRender.cite"] = Cite.ToString(); if (DateTime is not null) { try { - attributes["datetime"] = (DateTime is PSObject psObject ? psObject.BaseObject : DateTime) switch { + $attributesToRender.datetime"] = (DateTime is PSObject psObject ? psObject.BaseObject : DateTime) switch { DateOnly value => value.ToString("o"), DateTime value => value.ToString("o"), _ => throw new NotSupportedException("The specified date/time value is not supported.") diff --git a/src/Elements/New-LabelElement.psm1 b/src/Elements/New-LabelElement.psm1 index 3ef3f05..5f0a5c5 100644 --- a/src/Elements/New-LabelElement.psm1 +++ b/src/Elements/New-LabelElement.psm1 @@ -20,6 +20,6 @@ function New-HtmlLabelElement: NewElementCommand("label", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(For)) attributes["for"] = For; + if ($For) { $attributesToRender.for"] = For; } } diff --git a/src/Elements/New-LiElement.psm1 b/src/Elements/New-LiElement.psm1 index 37ea082..05e9aa1 100644 --- a/src/Elements/New-LiElement.psm1 +++ b/src/Elements/New-LiElement.psm1 @@ -20,6 +20,6 @@ function New-HtmlLiElement: NewElementCommand("li", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Value is not null) attributes["value"] = Value.Value + if (Value is not null) $attributesToRender.value"] = Value.Value } } diff --git a/src/Elements/New-LinkElement.psm1 b/src/Elements/New-LinkElement.psm1 index 1813872..3d82069 100644 --- a/src/Elements/New-LinkElement.psm1 +++ b/src/Elements/New-LinkElement.psm1 @@ -65,13 +65,13 @@ function New-HtmlLinkElement: NewElementCommand("link", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["rel"] = string.Join(' ', Rel).Trim(); - attributes["href"] = Href.ToString(); - if (-not [string]::IsNullOrWhiteSpace(As)) attributes["as"] = As; - if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (-not [string]::IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; - if (-not [string]::IsNullOrWhiteSpace(Media)) attributes["media"] = Media; - if (Sizes.Length > 0) attributes["sizes"] = string.Join(' ', Sizes).Trim(); - if (-not [string]::IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + $attributesToRender.rel"] = string.Join(' ', Rel).Trim(); + $attributesToRender.href"] = Href.ToString(); + if ($As) { $attributesToRender.as"] = As; + if (CrossOrigin is not null) $attributesToRender.crossorigin"] = CrossOrigin; + if ($Integrity) { $attributesToRender.integrity"] = Integrity; + if ($Media) { $attributesToRender.media"] = Media; + if (Sizes.Length > 0) $attributesToRender.sizes"] = string.Join(' ', Sizes).Trim(); + if ($Type) { $attributesToRender.type"] = Type; } } diff --git a/src/Elements/New-MapElement.psm1 b/src/Elements/New-MapElement.psm1 index 018f364..a79d43a 100644 --- a/src/Elements/New-MapElement.psm1 +++ b/src/Elements/New-MapElement.psm1 @@ -20,6 +20,6 @@ function New-HtmlMapElement: NewElementCommand("map", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if ($Name) { $attributesToRender.name"] = Name; } } diff --git a/src/Elements/New-MetaElement.psm1 b/src/Elements/New-MetaElement.psm1 index d5f05f3..506e90b 100644 --- a/src/Elements/New-MetaElement.psm1 +++ b/src/Elements/New-MetaElement.psm1 @@ -46,15 +46,15 @@ function New-HtmlMetaElement: NewElementCommand("meta", isVoid: true) { switch (ParameterSetName) { case nameof(Charset): - attributes["charset"] = Charset; + $attributesToRender.charset"] = Charset; break; case nameof(HttpEquiv): - attributes["http-equiv"] = HttpEquiv; - attributes["content"] = Content; + $attributesToRender.http-equiv"] = HttpEquiv; + $attributesToRender.content"] = Content; break; case nameof(Name): - attributes["name"] = Name; - attributes["content"] = Content; + $attributesToRender.name"] = Name; + $attributesToRender.content"] = Content; break; } } diff --git a/src/Elements/New-MeterElement.psm1 b/src/Elements/New-MeterElement.psm1 index 4589165..68ebf19 100644 --- a/src/Elements/New-MeterElement.psm1 +++ b/src/Elements/New-MeterElement.psm1 @@ -50,11 +50,11 @@ function New-HtmlMeterElement: NewElementCommand("meter", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (High is not null) attributes["high"] = High.Value - if (Low is not null) attributes["low"] = Low.Value - if (Max is not null) attributes["max"] = Max.Value - if (Min is not null) attributes["min"] = Min.Value - if (Optimum is not null) attributes["optimum"] = Optimum.Value - if (Value is not null) attributes["value"] = Value.Value + if (High is not null) $attributesToRender.high"] = High.Value + if (Low is not null) $attributesToRender.low"] = Low.Value + if (Max is not null) $attributesToRender.max"] = Max.Value + if (Min is not null) $attributesToRender.min"] = Min.Value + if (Optimum is not null) $attributesToRender.optimum"] = Optimum.Value + if (Value is not null) $attributesToRender.value"] = Value.Value } } diff --git a/src/Elements/New-ObjectElement.psm1 b/src/Elements/New-ObjectElement.psm1 index ea0de19..c6bacb0 100644 --- a/src/Elements/New-ObjectElement.psm1 +++ b/src/Elements/New-ObjectElement.psm1 @@ -54,11 +54,11 @@ function New-HtmlObjectElement: NewElementCommand("object", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["data"] = Data.ToString(); - attributes["type"] = Type; - if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (Height >= 0) attributes["height"] = Height - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Width >= 0) attributes["width"] = Width + $attributesToRender.data"] = Data.ToString(); + $attributesToRender.type"] = Type; + if ($Form) { $attributesToRender.form"] = Form; + if (Height >= 0) $attributesToRender.height"] = Height + if ($Name) { $attributesToRender.name"] = Name; + if (Width >= 0) $attributesToRender.width"] = Width } } diff --git a/src/Elements/New-OlElement.psm1 b/src/Elements/New-OlElement.psm1 index d5a1af3..767daef 100644 --- a/src/Elements/New-OlElement.psm1 +++ b/src/Elements/New-OlElement.psm1 @@ -33,8 +33,8 @@ function New-HtmlOlElement: NewElementCommand("ol", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Reversed) attributes["reversed"] = true; - if (Start is not null) attributes["start"] = Start.Value - if (Type is not null) attributes["type"] = Type; + if (Reversed) $attributesToRender.reversed"] = true; + if (Start is not null) $attributesToRender.start"] = Start.Value + if (Type is not null) $attributesToRender.type"] = Type; } } diff --git a/src/Elements/New-OptgroupElement.psm1 b/src/Elements/New-OptgroupElement.psm1 index 93c375a..055ab32 100644 --- a/src/Elements/New-OptgroupElement.psm1 +++ b/src/Elements/New-OptgroupElement.psm1 @@ -26,7 +26,7 @@ function New-HtmlOptgroupElement: NewElementCommand("optgroup", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["label"] = Label; - if (Disabled) attributes["disabled"] = true; + $attributesToRender.label"] = Label; + if (Disabled) $attributesToRender.disabled"] = true; } } diff --git a/src/Elements/New-OptionElement.psm1 b/src/Elements/New-OptionElement.psm1 index d47dc50..b05b710 100644 --- a/src/Elements/New-OptionElement.psm1 +++ b/src/Elements/New-OptionElement.psm1 @@ -38,9 +38,9 @@ function New-HtmlOptionElement: NewElementCommand("option", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Disabled) attributes["disabled"] = true; - if (-not [string]::IsNullOrWhiteSpace(Label)) attributes["label"] = Label; - if (Selected) attributes["selected"] = true; - if (Value is not null) attributes["value"] = Value; + if (Disabled) $attributesToRender.disabled"] = true; + if ($Label) { $attributesToRender.label"] = Label; + if (Selected) $attributesToRender.selected"] = true; + if (Value is not null) $attributesToRender.value"] = Value; } } diff --git a/src/Elements/New-OutputElement.psm1 b/src/Elements/New-OutputElement.psm1 index b86188e..2101869 100644 --- a/src/Elements/New-OutputElement.psm1 +++ b/src/Elements/New-OutputElement.psm1 @@ -32,8 +32,8 @@ function New-HtmlOutputElement: NewElementCommand("output", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (For.Length > 0) attributes["for"] = string.Join(' ', For).Trim(); - if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if (For.Length > 0) $attributesToRender.for"] = string.Join(' ', For).Trim(); + if ($Form) { $attributesToRender.form"] = Form; + if ($Name) { $attributesToRender.name"] = Name; } } diff --git a/src/Elements/New-ProgressElement.psm1 b/src/Elements/New-ProgressElement.psm1 index 4f7dfc8..7207d2f 100644 --- a/src/Elements/New-ProgressElement.psm1 +++ b/src/Elements/New-ProgressElement.psm1 @@ -28,7 +28,7 @@ function New-HtmlProgressElement: NewElementCommand("progress", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Max is not null) attributes["max"] = Max.Value - if (Value is not null) attributes["value"] = Value.Value + if (Max is not null) $attributesToRender.max"] = Max.Value + if (Value is not null) $attributesToRender.value"] = Value.Value } } diff --git a/src/Elements/New-QElement.psm1 b/src/Elements/New-QElement.psm1 index b0bda80..8109048 100644 --- a/src/Elements/New-QElement.psm1 +++ b/src/Elements/New-QElement.psm1 @@ -20,6 +20,6 @@ function New-HtmlQElement: NewElementCommand("q", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Cite is not null) attributes["cite"] = Cite.ToString(); + if (Cite is not null) $attributesToRender.cite"] = Cite.ToString(); } } diff --git a/src/Elements/New-ScriptElement.psm1 b/src/Elements/New-ScriptElement.psm1 index daf09f7..582286e 100644 --- a/src/Elements/New-ScriptElement.psm1 +++ b/src/Elements/New-ScriptElement.psm1 @@ -51,11 +51,11 @@ function New-HtmlScriptElement: NewElementCommand("script", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (Src is not null) attributes["src"] = Src.ToString(); - if (Async) attributes["async"] = true; - if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (Defer) attributes["defer"] = true; - if (-not [string]::IsNullOrWhiteSpace(Integrity)) attributes["integrity"] = Integrity; - if (-not [string]::IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + if (Src is not null) $attributesToRender.src"] = Src.ToString(); + if (Async) $attributesToRender.async"] = true; + if (CrossOrigin is not null) $attributesToRender.crossorigin"] = CrossOrigin; + if (Defer) $attributesToRender.defer"] = true; + if ($Integrity) { $attributesToRender.integrity"] = Integrity; + if ($Type) { $attributesToRender.type"] = Type; } } diff --git a/src/Elements/New-SelectElement.psm1 b/src/Elements/New-SelectElement.psm1 index d738f64..7fa9d12 100644 --- a/src/Elements/New-SelectElement.psm1 +++ b/src/Elements/New-SelectElement.psm1 @@ -57,12 +57,12 @@ function New-HtmlSelectElement: NewElementCommand("select", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); - if (Disabled) attributes["disabled"] = true; - if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (Multiple) attributes["multiple"] = true; - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (Required) attributes["required"] = true; - if (Size >= 0) attributes["size"] = Size + if (AutoComplete.Length > 0) $attributesToRender.autocomplete"] = string.Join(' ', AutoComplete).Trim(); + if (Disabled) $attributesToRender.disabled"] = true; + if ($Form) { $attributesToRender.form"] = Form; + if (Multiple) $attributesToRender.multiple"] = true; + if ($Name) { $attributesToRender.name"] = Name; + if (Required) $attributesToRender.required"] = true; + if (Size >= 0) $attributesToRender.size"] = Size } } diff --git a/src/Elements/New-SlotElement.psm1 b/src/Elements/New-SlotElement.psm1 index 305ddcb..2064e5e 100644 --- a/src/Elements/New-SlotElement.psm1 +++ b/src/Elements/New-SlotElement.psm1 @@ -20,6 +20,6 @@ function New-HtmlSlotElement: NewElementCommand("slot", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; + if ($Name) { $attributesToRender.name"] = Name; } } diff --git a/src/Elements/New-SourceElement.psm1 b/src/Elements/New-SourceElement.psm1 index 4484af6..e73672c 100644 --- a/src/Elements/New-SourceElement.psm1 +++ b/src/Elements/New-SourceElement.psm1 @@ -62,19 +62,19 @@ function New-HtmlSourceElement: NewElementCommand("source", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(Type)) attributes["type"] = Type; + if ($Type) { $attributesToRender.type"] = Type; switch (ParameterSetName) { case nameof(Src): - attributes["src"] = Src.ToString(); + $attributesToRender.src"] = Src.ToString(); break; case nameof(SrcSet): - attributes["srcset"] = string.Join(", ", SrcSet); - if (Height >= 0) attributes["height"] = Height - if (-not [string]::IsNullOrWhiteSpace(Media)) attributes["media"] = Media; - if (Sizes.Length > 0) attributes["sizes"] = string.Join(", ", Sizes); - if (Width >= 0) attributes["width"] = Width + $attributesToRender.srcset"] = string.Join(", ", SrcSet); + if (Height >= 0) $attributesToRender.height"] = Height + if ($Media) { $attributesToRender.media"] = Media; + if (Sizes.Length > 0) $attributesToRender.sizes"] = string.Join(", ", Sizes); + if (Width >= 0) $attributesToRender.width"] = Width break; } } diff --git a/src/Elements/New-StyleElement.psm1 b/src/Elements/New-StyleElement.psm1 index a49cd36..b333be2 100644 --- a/src/Elements/New-StyleElement.psm1 +++ b/src/Elements/New-StyleElement.psm1 @@ -20,6 +20,6 @@ function New-HtmlStyleElement: NewElementCommand("style", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(Media)) attributes["media"] = Media; + if ($Media) { $attributesToRender.media"] = Media; } } diff --git a/src/Elements/New-TdElement.psm1 b/src/Elements/New-TdElement.psm1 index 6c4f62d..0603607 100644 --- a/src/Elements/New-TdElement.psm1 +++ b/src/Elements/New-TdElement.psm1 @@ -34,8 +34,8 @@ function New-HtmlTdElement: NewElementCommand("td", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (ColSpan >= 0) attributes["colspan"] = ColSpan - if (Headers.Length > 0) attributes["headers"] = string.Join(' ', Headers).Trim(); - if (RowSpan >= 0) attributes["rowspan"] = RowSpan + if (ColSpan >= 0) $attributesToRender.colspan"] = ColSpan + if (Headers.Length > 0) $attributesToRender.headers"] = string.Join(' ', Headers).Trim(); + if (RowSpan >= 0) $attributesToRender.rowspan"] = RowSpan } } diff --git a/src/Elements/New-TemplateElement.psm1 b/src/Elements/New-TemplateElement.psm1 index 000fc53..4f370c3 100644 --- a/src/Elements/New-TemplateElement.psm1 +++ b/src/Elements/New-TemplateElement.psm1 @@ -39,9 +39,9 @@ function New-HtmlTemplateElement: NewElementCommand("template", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (ShadowRootMode is not null) attributes["shadowrootmode"] = ShadowRootMode; - if (ShadowRootClonable) attributes["shadowrootclonable"] = true; - if (ShadowRootDelegatesFocus) attributes["shadowrootdelegatesfocus"] = true; - if (ShadowRootSerializable) attributes["shadowrootserializable"] = true; + if (ShadowRootMode is not null) $attributesToRender.shadowrootmode"] = ShadowRootMode; + if (ShadowRootClonable) $attributesToRender.shadowrootclonable"] = true; + if (ShadowRootDelegatesFocus) $attributesToRender.shadowrootdelegatesfocus"] = true; + if (ShadowRootSerializable) $attributesToRender.shadowrootserializable"] = true; } } diff --git a/src/Elements/New-TextareaElement.psm1 b/src/Elements/New-TextareaElement.psm1 index e0863ba..ebf5b95 100644 --- a/src/Elements/New-TextareaElement.psm1 +++ b/src/Elements/New-TextareaElement.psm1 @@ -104,19 +104,19 @@ function New-HtmlTextareaElement: NewElementCommand("textarea", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (AutoComplete.Length > 0) attributes["autocomplete"] = string.Join(' ', AutoComplete).Trim(); - if (AutoCorrect is not null) attributes["autocorrect"] = AutoCorrect; - if (Cols > 0) attributes["cols"] = Cols - if (-not [string]::IsNullOrWhiteSpace(DirName)) attributes["dirname"] = DirName; - if (Disabled) attributes["disabled"] = true; - if (-not [string]::IsNullOrWhiteSpace(Form)) attributes["form"] = Form; - if (MaxLength >= 0) attributes["maxlength"] = MaxLength - if (MinLength >= 0) attributes["minlength"] = MinLength - if (-not [string]::IsNullOrWhiteSpace(Name)) attributes["name"] = Name; - if (-not [string]::IsNullOrWhiteSpace(Placeholder)) attributes["placeholder"] = Placeholder; - if (ReadOnly) attributes["readonly"] = true; - if (Required) attributes["required"] = true; - if (Rows > 0) attributes["rows"] = Rows - if (Wrap is not null) attributes["wrap"] = Wrap; + if (AutoComplete.Length > 0) $attributesToRender.autocomplete"] = string.Join(' ', AutoComplete).Trim(); + if (AutoCorrect is not null) $attributesToRender.autocorrect"] = AutoCorrect; + if (Cols > 0) $attributesToRender.cols"] = Cols + if ($DirName) { $attributesToRender.dirname"] = DirName; + if (Disabled) $attributesToRender.disabled"] = true; + if ($Form) { $attributesToRender.form"] = Form; + if (MaxLength >= 0) $attributesToRender.maxlength"] = MaxLength + if (MinLength >= 0) $attributesToRender.minlength"] = MinLength + if ($Name) { $attributesToRender.name"] = Name; + if ($Placeholder) { $attributesToRender.placeholder"] = Placeholder; + if (ReadOnly) $attributesToRender.readonly"] = true; + if (Required) $attributesToRender.required"] = true; + if (Rows > 0) $attributesToRender.rows"] = Rows + if (Wrap is not null) $attributesToRender.wrap"] = Wrap; } } diff --git a/src/Elements/New-ThElement.psm1 b/src/Elements/New-ThElement.psm1 index d7aa804..8b75251 100644 --- a/src/Elements/New-ThElement.psm1 +++ b/src/Elements/New-ThElement.psm1 @@ -47,10 +47,10 @@ function New-HtmlThElement: NewElementCommand("th", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (-not [string]::IsNullOrWhiteSpace(Abbr)) attributes["abbr"] = Abbr; - if (ColSpan >= 0) attributes["colspan"] = ColSpan - if (Headers.Length > 0) attributes["headers"] = string.Join(' ', Headers).Trim(); - if (RowSpan >= 0) attributes["rowspan"] = RowSpan - if (Scope is not null) attributes["scope"] = Scope; + if ($Abbr) { $attributesToRender.abbr"] = Abbr; + if (ColSpan >= 0) $attributesToRender.colspan"] = ColSpan + if (Headers.Length > 0) $attributesToRender.headers"] = string.Join(' ', Headers).Trim(); + if (RowSpan >= 0) $attributesToRender.rowspan"] = RowSpan + if (Scope is not null) $attributesToRender.scope"] = Scope; } } diff --git a/src/Elements/New-TimeElement.psm1 b/src/Elements/New-TimeElement.psm1 index 025a30f..fd72353 100644 --- a/src/Elements/New-TimeElement.psm1 +++ b/src/Elements/New-TimeElement.psm1 @@ -24,7 +24,7 @@ function New-HtmlTimeElement: NewElementCommand("time", isVoid: false) { if (DateTime is not null) { try { - attributes["datetime"] = (DateTime is PSObject psObject ? psObject.BaseObject : DateTime) switch { + $attributesToRender.datetime"] = (DateTime is PSObject psObject ? psObject.BaseObject : DateTime) switch { DateOnly value => value.ToString("o"), DateTime value => value.ToString("o"), TimeOnly value => value.ToString("o"), diff --git a/src/Elements/New-TrackElement.psm1 b/src/Elements/New-TrackElement.psm1 index 2df1063..9fe630b 100644 --- a/src/Elements/New-TrackElement.psm1 +++ b/src/Elements/New-TrackElement.psm1 @@ -46,10 +46,10 @@ function New-HtmlTrackElement: NewElementCommand("track", isVoid: true) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - attributes["src"] = Src.ToString(); - if (Default) attributes["default"] = true; - if (Kind is not null) attributes["kind"] = Kind; - if (-not [string]::IsNullOrWhiteSpace(Label)) attributes["label"] = Label; - if (SrcLang is not null) attributes["srclang"] = SrcLang.Name; + $attributesToRender.src"] = Src.ToString(); + if (Default) $attributesToRender.default"] = true; + if (Kind is not null) $attributesToRender.kind"] = Kind; + if ($Label) { $attributesToRender.label"] = Label; + if (SrcLang is not null) $attributesToRender.srclang"] = SrcLang.Name; } } diff --git a/src/Elements/New-VideoElement.psm1 b/src/Elements/New-VideoElement.psm1 index 819cdbe..f493770 100644 --- a/src/Elements/New-VideoElement.psm1 +++ b/src/Elements/New-VideoElement.psm1 @@ -96,18 +96,18 @@ function New-HtmlVideoElement: NewElementCommand("video", isVoid: false) { /// The attribute collection to populate. protected override void RenderAttributes(IDictionary attributes) { base.RenderAttributes(attributes); - if (AutoPlay) attributes["autoplay"] = true; - if (Controls) attributes["controls"] = true; - if (CrossOrigin is not null) attributes["crossorigin"] = CrossOrigin; - if (DisablePictureInPicture) attributes["disablepictureinpicture"] = true; - if (DisableRemotePlayback) attributes["disableremoteplayback"] = true; - if (Height >= 0) attributes["height"] = Height - if (Loop) attributes["loop"] = true; - if (Muted) attributes["muted"] = true; - if (PlaysInline) attributes["playsinline"] = true; - if (Poster is not null) attributes["poster"] = Poster.ToString(); - if (Preload is not null) attributes["preload"] = Preload; - if (Src is not null) attributes["src"] = Src.ToString(); - if (Width >= 0) attributes["width"] = Width + if (AutoPlay) $attributesToRender.autoplay"] = true; + if (Controls) $attributesToRender.controls"] = true; + if (CrossOrigin is not null) $attributesToRender.crossorigin"] = CrossOrigin; + if (DisablePictureInPicture) $attributesToRender.disablepictureinpicture"] = true; + if (DisableRemotePlayback) $attributesToRender.disableremoteplayback"] = true; + if (Height >= 0) $attributesToRender.height"] = Height + if (Loop) $attributesToRender.loop"] = true; + if (Muted) $attributesToRender.muted"] = true; + if (PlaysInline) $attributesToRender.playsinline"] = true; + if (Poster is not null) $attributesToRender.poster"] = Poster.ToString(); + if (Preload is not null) $attributesToRender.preload"] = Preload; + if (Src is not null) $attributesToRender.src"] = Src.ToString(); + if (Width >= 0) $attributesToRender.width"] = Width } } diff --git a/test/Elements/New-AreaElement.Tests.ps1 b/test/Elements/New-AreaElement.Tests.ps1 index 042fc48..1d58c55 100644 --- a/test/Elements/New-AreaElement.Tests.ps1 +++ b/test/Elements/New-AreaElement.Tests.ps1 @@ -8,7 +8,7 @@ Describe "New-AreaElement" { } It 'should support the "shape" and "coords" attributes' { - $area = area -Href Index.html -shape circle -coords 100, 200, 64.7 + $area = area -Href Index.html -Shape circle -Coords 100, 200, 64.7 $area | Should -BeLikeExactly "