Created
May 8, 2024 20:15
-
-
Save santisq/e3ecfbf19ce2d385d0ef0dec1f0d4c8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$map = @{ | |
color = 'red' | |
person = @{ | |
firstname = 'Bob' | |
lastname = 'Smith' | |
} | |
gender = 'his' | |
} | |
$template = @' | |
This a block of text. Here is a color {{ color }}. | |
{{ person.firstname }} should be able to read this with {{ gender }} name in it. | |
'@ | |
[regex]::Replace($template, '\{{\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