Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 812 Bytes

README.md

File metadata and controls

54 lines (42 loc) · 812 Bytes

PSTemplate

Use and fill templates in PowerShell via a simple syntax.

Installation

Install-Module PSTemplate

Usage

One-liner

Fill-Template -Template "simple {{Type}} but could be a here-string" -Variables @{'Type' = 'string'}

outputs:

simple string but could be a here-string

More Common

$template = @"
{{line1}}
line2
{{line3}}
"@

$tokens = @{
    "line1" = "Line 1"
    "line3" = "Line 3"
}

Fill-Template -Template $template -Variables $tokens

outputs:

Line 1
line2
Line 3

From and to File

$tokens = @{
    "line1" = "Line 1"
    "line3" = "Line 3"
}

Get-Content "C:\temp\Lines.template" | Fill-Template -Template $template -Variables $tokens | Out-File "C:\temp\lines.filled" -Encoding Utf8