Skip to content

Commit d842880

Browse files
fix for junk in code#127
1 parent 7f0f518 commit d842880

File tree

1 file changed

+32
-41
lines changed

1 file changed

+32
-41
lines changed

Public/New-HTML.ps1

+32-41
Original file line numberDiff line numberDiff line change
@@ -45,46 +45,39 @@ Function New-HTML {
4545
$FooterHTML = @()
4646

4747

48-
$MainHTML = foreach ($_ in $TempOutputHTML) {
49-
if ($_ -is [PSCustomObject]) {
50-
if ($_.Type -eq 'Footer') {
51-
$FooterHTML = $_.Output
52-
} elseif ($_.Type -eq 'Header') {
53-
$HeaderHTML = $_.Output
48+
$MainHTML = foreach ($ObjectTemp in $TempOutputHTML) {
49+
if ($ObjectTemp -is [PSCustomObject]) {
50+
if ($ObjectTemp.Type -eq 'Footer') {
51+
$FooterHTML = foreach ($_ in $ObjectTemp.Output) {
52+
# this gets rid of any non-strings
53+
# it's added here to track nested tabs
54+
if ($_ -isnot [System.Collections.IDictionary]) { $_ }
55+
}
56+
} elseif ($ObjectTemp.Type -eq 'Header') {
57+
$HeaderHTML = foreach ($_ in $ObjectTemp.Output) {
58+
# this gets rid of any non-strings
59+
# it's added here to track nested tabs
60+
if ($_ -isnot [System.Collections.IDictionary]) { $_ }
61+
}
5462
} else {
55-
if ($_.Output) {
56-
# this gets rid of any non-strings
57-
# it's added here to track nested tabs
58-
if ($_.Output -isnot [System.Collections.IDictionary]) {
59-
$_.Output
63+
if ($ObjectTemp.Output) {
64+
# this gets rid of any non-strings
65+
# it's added here to track nested tabs
66+
foreach ($SubObject in $ObjectTemp.Output) {
67+
if ($SubObject -isnot [System.Collections.IDictionary]) {
68+
$SubObject
69+
}
6070
}
6171
}
6272
}
6373
} else {
64-
# this gets rid of any non-strings
65-
# it's added here to track nested tabs
66-
if ($_ -isnot [System.Collections.IDictionary]) {
67-
$_
74+
# this gets rid of any non-strings
75+
# it's added here to track nested tabs
76+
if ($ObjectTemp -isnot [System.Collections.IDictionary]) {
77+
$ObjectTemp
6878
}
6979
}
7080
}
71-
<#
72-
if ($MainHTML.Count -eq 0) {
73-
# this gets rid of any non-strings
74-
# it's added here to track nested tabs
75-
$MainHTML = foreach ($_ in $MainHTML) {
76-
if ($_ -isnot [System.Collections.IDictionary]) {
77-
$_
78-
}
79-
}
80-
} else {
81-
$MainHTML = foreach ($_ in $MainHTML) {
82-
if ($_ -isnot [System.Collections.IDictionary]) {
83-
$_
84-
}
85-
}
86-
}
87-
#>
8881

8982
$Features = Get-FeaturesInUse -PriorityFeatures 'JQuery', 'DataTables', 'Tabs'
9083

@@ -109,30 +102,28 @@ Function New-HTML {
109102
New-HTMLTag -Tag 'meta' -Attributes @{ name = 'revised'; content = $CurrentDate } -SelfClosing
110103
New-HTMLTag -Tag 'title' { $TitleText }
111104

112-
if($null -ne $FavIcon){
105+
if ($null -ne $FavIcon) {
113106
$Extension = [System.IO.Path]::GetExtension($FavIcon)
114107
if ($Extension -in @('.png', '.jpg', 'jpeg', '.svg', '.ico')) {
115-
switch($FavIcon.Scheme){
108+
switch ($FavIcon.Scheme) {
116109
"file" {
117-
if(Test-Path -Path $FavIcon.OriginalString){
110+
if (Test-Path -Path $FavIcon.OriginalString) {
118111
$FavIcon = Get-Item -Path $FavIcon.OriginalString
119112
$FavIconImageBinary = Convert-ImageToBinary -ImageFile $FavIcon
120-
New-HTMLTag -Tag 'link' -Attributes @{rel = 'icon'; href = "$FavIconImageBinary"; type = 'image/x-icon'}
121-
}
122-
else{
113+
New-HTMLTag -Tag 'link' -Attributes @{rel = 'icon'; href = "$FavIconImageBinary"; type = 'image/x-icon' }
114+
} else {
123115
Write-Warning -Message "The path to the FavIcon image could not be resolved."
124116
}
125117
}
126118
"https" {
127119
$FavIcon = $FavIcon.OriginalString
128-
New-HTMLTag -Tag 'link' -Attributes @{rel = 'icon'; href = "$FavIcon"; type = 'image/x-icon'}
120+
New-HTMLTag -Tag 'link' -Attributes @{rel = 'icon'; href = "$FavIcon"; type = 'image/x-icon' }
129121
}
130122
default {
131123
Write-Warning -Message "The path to the FavIcon image could not be resolved."
132124
}
133125
}
134-
}
135-
else{
126+
} else {
136127
Write-Warning -Message "File extension `'$Extension`' is not supported as a FavIcon image.`nPlease use images with these extensions: '.png', '.jpg', 'jpeg', '.svg', '.ico'"
137128
}
138129
}

0 commit comments

Comments
 (0)