Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SeeminglyScience/PSStringTemplate
Create and render templates using the StringTemplate template engine.
https://github.com/SeeminglyScience/PSStringTemplate
code-generation powershell template
Last synced: 3 months ago
JSON representation
Create and render templates using the StringTemplate template engine.
- Host: GitHub
- URL: https://github.com/SeeminglyScience/PSStringTemplate
- Owner: SeeminglyScience
- License: mit
- Created: 2017-05-13T13:57:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-11T19:00:17.000Z (almost 7 years ago)
- Last Synced: 2024-06-22T18:46:59.231Z (5 months ago)
- Topics: code-generation, powershell, template
- Language: C#
- Size: 74.2 KB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - SeeminglyScience/PSStringTemplate - Create and render templates using the StringTemplate template engine. (C# #)
README
# PSStringTemplate
The PSStringTemplate module provides a PowerShell friendly interface for creating templates using the
[StringTemplate4](https://github.com/antlr/antlrcs) template engine.This project adheres to the Contributor Covenant [code of conduct](https://github.com/SeeminglyScience/PSStringTemplate/tree/master/docs/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].## Build Status
|AppVeyor (Windows)|CircleCI (Linux)|CodeCov|
|---|---|---|
|[![Build status](https://ci.appveyor.com/api/projects/status/3uvr9oq297uhvj8p?svg=true)](https://ci.appveyor.com/project/SeeminglyScience/psstringtemplate)|[![CircleCI](https://circleci.com/gh/SeeminglyScience/PSStringTemplate.svg?style=svg)](https://circleci.com/gh/SeeminglyScience/PSStringTemplate)|[![codecov](https://codecov.io/gh/SeeminglyScience/PSStringTemplate/branch/master/graph/badge.svg)](https://codecov.io/gh/SeeminglyScience/PSStringTemplate)|## Documentation
Check out our **[documentation](https://github.com/SeeminglyScience/PSStringTemplate/tree/master/docs/en-US/PSStringTemplate.md)** for information about how to use this project. For more details on the template definition syntax specifically see the documentation for the [StringTemplate4 project](https://github.com/antlr/stringtemplate4/blob/master/doc/index.md).
## Installation
### Gallery
```powershell
Install-Module PSStringTemplate -Scope CurrentUser
```### Source
```powershell
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
```powershell
Invoke-StringTemplate -Definition ' is very !' -Parameters @{
language = 'PowerShell'
adjective = 'cool'
}
``````txt
PowerShell is very cool!
```### Anonymous template with object as parameters
```powershell
$definition = 'Name: <\n>Commands: '
Invoke-StringTemplate -Definition $definition -Parameters (Get-Module PSReadLine)
``````txt
Name: PSReadline
Commands: Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Set-PSReadlineOption, PSConsoleHostReadline
```### TemplateGroup definition
```powershell
$definition = @'
Param(parameter) ::= "[] $"
Method(member) ::= <<
[] static () {
throw [NotImplementedException]::new()
}
>>
Class(Name, DeclaredMethods) ::= <<
class MyClass : {
}
>>
'@
$group = New-StringTemplateGroup -Definition $definition
$group | Invoke-StringTemplate -Name Class -Parameters ([System.Runtime.InteropServices.ICustomMarshaler])
``````txt
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](https://github.com/SeeminglyScience/ClassExplorer/tree/master/docs/CONTRIBUTING.md) to learn more.