SkillAgentSearch skills...

PSStringTemplate

Create and render templates using the StringTemplate template engine.

Install / Use

/learn @SeeminglyScience/PSStringTemplate
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

PSStringTemplate

The PSStringTemplate module provides a PowerShell friendly interface for creating templates using the StringTemplate4 template engine.

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to seeminglyscience@gmail.com.

Build Status

|AppVeyor (Windows)|CircleCI (Linux)|CodeCov| |---|---|---| |Build status|CircleCI|codecov|

Documentation

Check out our documentation for information about how to use this project. For more details on the template definition syntax specifically see the documentation for the StringTemplate4 project.

Installation

Gallery

Install-Module PSStringTemplate -Scope CurrentUser

Source

git clone 'https://github.com/SeeminglyScience/PSStringTemplate.git'
Set-Location ./PSStringTemplate
Install-Module platyPS, Pester, InvokeBuild -Force
Import-Module platyPS, Pester, InvokeBuild
Invoke-Build -Task Install

Usage

Anonymous template with dictionary parameters

Invoke-StringTemplate -Definition '<language> is very <adjective>!' -Parameters @{
    language = 'PowerShell'
    adjective = 'cool'
}
PowerShell is very cool!

Anonymous template with object as parameters

$definition = 'Name: <Name><\n>Commands: <ExportedCommands; separator=", ">'
Invoke-StringTemplate -Definition $definition -Parameters (Get-Module PSReadLine)
Name: PSReadline
Commands: Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Set-PSReadlineOption, PSConsoleHostReadline

TemplateGroup definition

$definition = @'
    Param(parameter) ::= "[<parameter.ParameterType.Name>] $<parameter.Name>"
    Method(member) ::= <<
[<member.ReturnType.Name>]<if(member.IsStatic)> static<endif> <member.Name> (<member.Parameters:Param(); separator=", ">) {
    throw [NotImplementedException]::new()
}
>>
    Class(Name, DeclaredMethods) ::= <<
class MyClass : <Name> {
    <DeclaredMethods:Method(); separator="\n\n">
}
>>
'@
$group = New-StringTemplateGroup -Definition $definition
$group | Invoke-StringTemplate -Name Class -Parameters ([System.Runtime.InteropServices.ICustomMarshaler])
class MyClass : ICustomMarshaler {
    [Object] MarshalNativeToManaged ([IntPtr] $pNativeData) {
        throw [NotImplementedException]::new()
    }

    [IntPtr] MarshalManagedToNative ([Object] $ManagedObj) {
        throw [NotImplementedException]::new()
    }

    [Void] CleanUpNativeData ([IntPtr] $pNativeData) {
        throw [NotImplementedException]::new()
    }

    [Void] CleanUpManagedData ([Object] $ManagedObj) {
        throw [NotImplementedException]::new()
    }

    [Int32] GetNativeDataSize () {
        throw [NotImplementedException]::new()
    }
}

Contributions Welcome!

We would love to incorporate community contributions into this project. If you would like to contribute code, documentation, tests, or bug reports, please read our Contribution Guide to learn more.

Related Skills

View on GitHub
GitHub Stars11
CategoryDevelopment
Updated5mo ago
Forks4

Languages

C#

Security Score

92/100

Audited on Oct 6, 2025

No findings