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.
AppVeyor (Windows) | CircleCI (Linux) | CodeCov |
---|---|---|
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.
Install-Module PSStringTemplate -Scope CurrentUser
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
Invoke-StringTemplate -Definition '<language> is very <adjective>!' -Parameters @{
language = 'PowerShell'
adjective = 'cool'
}
PowerShell is very cool!
$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
$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()
}
}
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.