File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Examples/Example-TableWithTags Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ Import-Module .\PSWriteHTML.psd1 - Force
2+
3+ $test = " <test>"
4+ New-HTML {
5+ New-HTMLTableOption - DataStore JavaScript - BoolAsString - ArrayJoinString ' <br>' - ArrayJoin
6+
7+ New-HTMLTab - Name ' Forest' {
8+ New-HTMLSection - HeaderText ' Summary' {
9+ New-HTMLTable - DataTable $test
10+ }
11+ }
12+ } - ShowHTML - FilePath " $PSScriptRoot \Example-TableWithTags.html" - Online
Original file line number Diff line number Diff line change 13211321 ArrayJoinString = $Script :HTMLSchema [' TableOptions' ][' DataStoreOptions' ].ArrayJoinString
13221322 }
13231323 $DataToInsert = $Table | ConvertTo-PrettyObject @convertToPrettyObjectSplat | ConvertTo-Json
1324+ if (-not $InvokeHTMLTags ) {
1325+ # If InvokeHTMLTags is not set, we need to escape HTML characters
1326+ # By default HTML tags are escaped when using DataStore HTML, but not when using JavaScript
1327+ # So we need to escape them here, so they don't break the JavaScript code
1328+ $DataToInsert = $DataToInsert -replace " <" , " <" -replace " >" , " >"
1329+ }
13241330 if ($DataToInsert.StartsWith (' [' )) {
13251331 $Script :HTMLSchema.CustomFooterJS [$DataStoreID ] = " var $DataStoreID = $DataToInsert ;"
13261332 } else {
13411347 ArrayJoinString = $Script :HTMLSchema [' TableOptions' ][' DataStoreOptions' ].ArrayJoinString
13421348 }
13431349 $DataToInsert = $Table | ConvertTo-PrettyObject @convertToPrettyObjectSplat | ConvertTo-Json
1350+ if (-not $InvokeHTMLTags ) {
1351+ # If InvokeHTMLTags is not set, we need to escape HTML characters
1352+ # By default HTML tags are escaped when using DataStore HTML, but not when using JavaScript
1353+ # So we need to escape them here, so they don't break the JavaScript code
1354+ $DataToInsert = $DataToInsert -replace " <" , " <" -replace " >" , " >"
1355+ }
13441356 if ($DataToInsert.StartsWith (' [' )) {
13451357 $Options = $Options.Replace (' "markerForDataReplacement"' , $DataToInsert )
13461358 } else {
You can’t perform that action at this time.
0 commit comments