Text replacement - LaurentDardenne/Template GitHub Wiki
The setting of the string replacement is based on a hashtable used by the Edit-String function :
$TemplateDefaultSettings=@{}
A key contains a regex pattern or a simple text.
The value of the key contains a scriptblock or a simple text.
#Substitute a token by the variable content :
# <%=$VariableName%> or <%=${VariableName}%>
$TemplateDefaultSettings.'(?ims)(<%=)(.*?)(%>)'= {
param($match)
$expr = $match.groups[2].value
$ExecutionContext.InvokeCommand.ExpandString($Expr)
}
All Keys are executed for each received string by Edit-String.
The Scriptblock is a MatchEvaluator.
$String|Edit-String -Setting $TemplateDefaultSettings