Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Functions/Public/a.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ Function a {
)
Process{




$CommonParameters = "tagname" + [System.Management.Automation.PSCmdlet]::CommonParameters + [System.Management.Automation.PSCmdlet]::OptionalCommonParameters
$CustomParameters = $PSBoundParameters.Keys | ? { $_ -notin $CommonParameters }

Expand Down Expand Up @@ -114,9 +111,5 @@ Function a {
Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType nonVoid
}



}


}
81 changes: 81 additions & 0 deletions Functions/Public/small.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Function small {
<#
.SYNOPSIS
Create a <small> element in an HTML document.

.DESCRIPTION
The <small> tag defines smaller text (and other side comments).


.EXAMPLE

small

Returns>

<small>
</small>
.EXAMPLE
small "woop1" -Class "class"

<small Class="class" >
woop1
</small>

.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
65 changes: 65 additions & 0 deletions Tests/small.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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 '^<small.*>' | should be $true
$string -match '.*</small>$' | should be $true

}

it "Testing content in child element"{
$string -match "^.*>woop<.*" | should be $true
}

it "Testing common parameters: Class"{
$string -match '^<small.*class="myclass".*>' | should be $true
}
it "Testing common parameters: ID"{
$string -match '^<small.*id="myid".*>' | should be $true
}
it "Testing common parameters: Style"{
$string -match '^<small.*style=".+".*>' | should be $true
}

it "Testing Attributes parameters"{

foreach($at in $CustomAtt.Keys){
$val = $null
$val = $CustomAtt[$at]
$string -match "^<small.*$at=`"$val`".*>" | should be $true
}


}


}

}

Pop-Location
2 changes: 1 addition & 1 deletion pshtml.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'pshtml.psm1'

# Version number of this module.
ModuleVersion = '0.5.16'
ModuleVersion = '0.5.17'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down