diff --git a/Functions/Public/a.ps1 b/Functions/Public/a.ps1 index 932c94ff..043591e8 100644 --- a/Functions/Public/a.ps1 +++ b/Functions/Public/a.ps1 @@ -81,9 +81,6 @@ Function a { ) Process{ - - - $CommonParameters = "tagname" + [System.Management.Automation.PSCmdlet]::CommonParameters + [System.Management.Automation.PSCmdlet]::OptionalCommonParameters $CustomParameters = $PSBoundParameters.Keys | ? { $_ -notin $CommonParameters } @@ -114,9 +111,5 @@ Function a { Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType nonVoid } - - } - - } \ No newline at end of file diff --git a/Functions/Public/small.ps1 b/Functions/Public/small.ps1 new file mode 100644 index 00000000..c6143e8b --- /dev/null +++ b/Functions/Public/small.ps1 @@ -0,0 +1,81 @@ +Function small { + <# + .SYNOPSIS + Create a element in an HTML document. + + .DESCRIPTION + The tag defines smaller text (and other side comments). + + + .EXAMPLE + + small + + Returns> + + + + .EXAMPLE + small "woop1" -Class "class" + + + woop1 + + + .Notes + Author: Stéphane van Gulick + Version: 2.0.0 + History: + 2018.10.04;@Stephanevg; Creation + + .LINK + https://github.com/Stephanevg/PSHTML + #> + [Cmdletbinding()] + Param( + + [Parameter(Mandatory=$false)] + [AllowEmptyString()] + [AllowNull()] + $Content, + + [AllowEmptyString()] + [AllowNull()] + [String]$Class, + + [String]$Id, + + [String]$Style, + + [Hashtable]$Attributes + ) + + $attr = "" + $CommonParameters = "tagname" + [System.Management.Automation.PSCmdlet]::CommonParameters + [System.Management.Automation.PSCmdlet]::OptionalCommonParameters + $CustomParameters = $PSBoundParameters.Keys | Where-Object -FilterScript { $_ -notin $CommonParameters } + + $htmltagparams = @{} + $tagname = "small" + if($CustomParameters){ + + foreach ($entry in $CustomParameters){ + + if($entry -eq "content"){ + + + $htmltagparams.$entry = $PSBoundParameters[$entry] + }else{ + $htmltagparams.$entry = "{0}" -f $PSBoundParameters[$entry] + } + } + } + + if($Attributes){ + $htmltagparams += $Attributes + } + + Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType nonVoid +} + +$CustomAtt = @{"MyAttribute1"='MyValue1';"MyAttribute2"="MyValue2"} +small -Attributes $CustomAtt \ No newline at end of file diff --git a/Tests/small.Tests.ps1 b/Tests/small.Tests.ps1 new file mode 100644 index 00000000..58f340a0 --- /dev/null +++ b/Tests/small.Tests.ps1 @@ -0,0 +1,65 @@ +$TestsPath = Split-Path $MyInvocation.MyCommand.Path + +#$FunctionsPath = join-Path -Path (get-item $TestsPath).Parent -ChildPath "Functions" + +$RootFolder = (get-item $TestsPath).Parent + +Push-Location -Path $RootFolder.FullName + +set-location -Path $RootFolder.FullName + +Write-Verbose "Importing module" + +import-module .\PSHTML -Force + +Context "Testing PSHTML"{ + Describe "Testing small" { + + + $Class = "MyClass" + $Id = "MyID" + $Style = "Background:green" + $CustomAtt = @{"MyAttribute1"='MyValue1';"MyAttribute2"="MyValue2"} + $string = small {"woop"} -Attributes $CustomAtt -Style $Style -Class $class -id $id + + if($string -is [array]){ + $string = $String -join "" + } + + it "Should contain opening and closing tags" { + $string -match '^' | should be $true + $string -match '.*$' | should be $true + + } + + it "Testing content in child element"{ + $string -match "^.*>woop<.*" | should be $true + } + + it "Testing common parameters: Class"{ + $string -match '^' | should be $true + } + it "Testing common parameters: ID"{ + $string -match '^' | should be $true + } + it "Testing common parameters: Style"{ + $string -match '^' | should be $true + } + + it "Testing Attributes parameters"{ + + foreach($at in $CustomAtt.Keys){ + $val = $null + $val = $CustomAtt[$at] + $string -match "^" | should be $true + } + + + } + + + } + +} + +Pop-Location \ No newline at end of file diff --git a/pshtml.psd1 b/pshtml.psd1 index eeefe230..cf0bf4e5 100644 --- a/pshtml.psd1 +++ b/pshtml.psd1 @@ -12,7 +12,7 @@ RootModule = 'pshtml.psm1' # Version number of this module. -ModuleVersion = '0.5.16' +ModuleVersion = '0.5.17' # Supported PSEditions # CompatiblePSEditions = @()