Skip to content

Instantly share code, notes, and snippets.

@santisq
Last active November 1, 2024 14:46
Show Gist options
  • Save santisq/e3ecfbf19ce2d385d0ef0dec1f0d4c8b to your computer and use it in GitHub Desktop.
Save santisq/e3ecfbf19ce2d385d0ef0dec1f0d4c8b to your computer and use it in GitHub Desktop.
$map = @{
color = 'red'
person = @{
firstname = 'Bob'
lastname = 'Smith'
}
gender = 'his'
}
$template = @'
This a block of text. Here is a color {{ color }}.
{{ person.firstname }} {{ person.lastname }} should be able to read this with {{ gender }} name in it.
'@
[regex]::Replace($template, '\{{\s*(\S+)\s*\}}', {
param($s)
foreach ($i in $s.Groups[1].Value.Split('.')) {
$map = $map[$i]
}
$map
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment