Table of Contents
PowerShell has a great templating engine already in Plaster, but I've found it difficult to work with. Scaffolding with Invoke-Plaster
is difficult, requiring you to specify the full path to the template you want to use. Authoring templates is complicated with a complex XML manifest file and a template syntax that is while very powerful, also not the friendliest to write. Packaging and sharing templates is an after thought at best. I believe that all of these traits lead to Plaster
not being used as much as a templating engine should be.
PShape
is a modern PowerShell templating and scaffolding engine designed to address all of these issues. When scaffolding you use a template's name, rather than having to specify a path. Authoring is greatly simplified with a slim manifest file, authored in JSON, with useful default behavior. The template files are authored using Moustache a very simple "logic-less" templating syntax. Packaging templates is as simple as creating a PowerShell module (a PShape template exists for that!) with a PShapes
directory and sharing is as easy as publishing that module to the PowerShell Gallery. My hope is that all of this means there will be plenty of templates contributed by the community, but PShape
comes with a core set of templates out of the box.
The following build tools are used in the creation of PShape
, but they are all (with the obvious exception of PowerShell Core 7) bootstrapped by the build.ps1
script.
Note: As a modern PowerShell templating engine there's currently a requirement for PowerShell Core 7. If you need to use PShape
on an older PowerShell version I'm taking pull requests. :)
PShape
is very friendly to use and is distributed as a PowerShell module in the PowerShell Gallery.
To use PShape
the first thing you'll need to do is install the module.
PS> Install-Module PShape -Scope CurrentUser
If you haven't already done so, you should import the PShape
module (consider adding this to your profile).
PS> Import-Module PShape
With PShape
imported you can get a list of the known templates (at this point it's likely only the default templates that come with the PShape
module).
PS> Get-PShapeTemplate
You can generate files from a template by simply specifying the template name.
PS> New-PShape -Name script -InputObject @{ name = 'myscript' }
You can read a lot more information about using PShape
by reading about_PShape
.
PS> Get-Help about_PShape
- Publish 1.0 package to the PowerShell Gallery
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Another great way to contribute is to simply create PShape
templates and publish them to the PowerShell Gallery. See about_PShape
for more information on how this is done.
Distributed under the MIT License. See LICENSE for more information.
William E. Kempf - @wekempf - [email protected]
Project Link: https://github.com/wekempf/pshape
The following projects were used by or inspired this project.