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
12 changes: 12 additions & 0 deletions Examples/Example-TableWithTags/Example-TableWithTags.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Import-Module .\PSWriteHTML.psd1 -Force

$test = "<test>"
New-HTML {
New-HTMLTableOption -DataStore JavaScript -BoolAsString -ArrayJoinString '<br>' -ArrayJoin

New-HTMLTab -Name 'Forest' {
New-HTMLSection -HeaderText 'Summary' {
New-HTMLTable -DataTable $test
}
}
} -ShowHTML -FilePath "$PSScriptRoot\Example-TableWithTags.html" -Online
12 changes: 12 additions & 0 deletions Public/New-HTMLTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,12 @@
ArrayJoinString = $Script:HTMLSchema['TableOptions']['DataStoreOptions'].ArrayJoinString
}
$DataToInsert = $Table | ConvertTo-PrettyObject @convertToPrettyObjectSplat | ConvertTo-Json
if (-not $InvokeHTMLTags) {
# If InvokeHTMLTags is not set, we need to escape HTML characters
# By default HTML tags are escaped when using DataStore HTML, but not when using JavaScript
# So we need to escape them here, so they don't break the JavaScript code
$DataToInsert = $DataToInsert -replace "<", "&lt;" -replace ">", "&gt;"
}
if ($DataToInsert.StartsWith('[')) {
$Script:HTMLSchema.CustomFooterJS[$DataStoreID] = "var $DataStoreID = $DataToInsert;"
} else {
Expand All @@ -1341,6 +1347,12 @@
ArrayJoinString = $Script:HTMLSchema['TableOptions']['DataStoreOptions'].ArrayJoinString
}
$DataToInsert = $Table | ConvertTo-PrettyObject @convertToPrettyObjectSplat | ConvertTo-Json
if (-not $InvokeHTMLTags) {
# If InvokeHTMLTags is not set, we need to escape HTML characters
# By default HTML tags are escaped when using DataStore HTML, but not when using JavaScript
# So we need to escape them here, so they don't break the JavaScript code
$DataToInsert = $DataToInsert -replace "<", "&lt;" -replace ">", "&gt;"
}
if ($DataToInsert.StartsWith('[')) {
$Options = $Options.Replace('"markerForDataReplacement"', $DataToInsert)
} else {
Expand Down
Loading