Skip to content

Commit

Permalink
Add function Set-PSCodeHealthPlaceholdersValue to replace the Placeho…
Browse files Browse the repository at this point in the history
…lders in the templates
  • Loading branch information
MathieuBuisson committed Jun 30, 2017
1 parent 20a0b7e commit b3698db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Function Set-PSCodeHealthPlaceholdersValue {
$TemplateContent = Get-Content -Path $TemplatePath

Foreach ( $Placeholder in $PlaceholdersData.GetEnumerator() ) {
$TemplateContent = $TemplateContent.ForEach('Replace',"{$($Placeholder.Key)}",$Placeholder.Value)
$PlaceholderPattern = '{{{0}}}' -f $Placeholder.Key
$TemplateContent = $TemplateContent.ForEach('Replace', $PlaceholderPattern, $Placeholder.Value)
}
$TemplateContent
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Describe 'Set-PSCodeHealthPlaceholdersValue' {
$PlaceholdersData = @{
REPORT_TITLE = 'StringValue1'
ANALYZED_PATH = 'StringValue2'
DATE = Get-Date -Format u
DATE = '2017-07-01 21:50:52Z'
}
$Result = Set-PSCodeHealthPlaceholdersValue -TemplatePath $MockedFile.FullName -PlaceholdersData $PlaceholdersData

Expand All @@ -40,6 +40,10 @@ Describe 'Set-PSCodeHealthPlaceholdersValue' {
$Result[1] | Should Be '</head>'
$Result[2] | Should Be '<body>'
}
It 'Replaces properly 3 placeholders in a line' {
$Result[5] |
Should Be ' PSCodeHealth Report - StringValue1 <small class="analyzed-path"> StringValue2 - 2017-07-01 21:50:52Z</small>'
}
}
}
}

0 comments on commit b3698db

Please sign in to comment.