Artifact df22f4b261b21b60dc85655f11b7e0aa37b8d4663de7c71ee4893b255e9151e0:
- File
Templates-and-Tables.ps1
— part of check-in
[ed9e3e6a75]
at
2018-06-10 14:04:00
on branch trunk
— This script generates an output file from a template and a driver table. Both of the inputs are files. The template file contains plain
(user:
Walter Mitty
size: 1296)
# encoding: ascii
# api: powershell
# title: Templates and Tables
# description: This script generates an output file from a template and a driver table. Both of the inputs are files. The template file contains plain
# version: 0.1
# type: script
# author: Walter Mitty
# license: CC0
# x-poshcode-id: 5915
# x-archived: 2015-07-03T01:44:43
# x-published: 2015-07-01T12:00:00
#
# text and embedded variables. The driver table has one column for each variable, and one row for each expansion to be generated.
#
<# This scriptlet is a table driven template tool.
It's a refinement of an earlier attempt.
It generates an output file from a template and
a driver table. The template file contains plain
text and embedded variables. The driver table has
one column for each variable, and one row for each
expansion to be generated.
2/15/2015
#>
param ($driver, $template, $out);
$OFS = "`r`n"
$list = Import-Csv $driver
[string]$pattern = Get-Content $template
Clear-Content $out -ErrorAction SilentlyContinue
foreach ($item in $list) {
foreach ($key in $item.psobject.properties) {
Set-variable -name $key.name -value $key.value
}
$ExecutionContext.InvokeCommand.ExpandString($pattern) >> $out
}