PSStringTemplate
Create and render templates using the StringTemplate template engine.
Install / Use
/learn @SeeminglyScience/PSStringTemplateREADME
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|
|---|---|---|
||
|
|
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
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
