Introducing PSHTML2023-06-12T02:10:21+00:00

Salutations,In this blog post, I would like to introduce a project on which I have been spending quite some time: PSHTML.I also want to announce that I have made the module availble on the PowerShell Gallery.

Anyone can download it, using the following simple command:

PSHTML in a few words

PSHTML is a DSL (Domain Specific Language) which allows one to create webpages without leaving your Powershell script.I understand that this can be a bit vague, so let’s showcase this using an example:.gist table { margin-bottom: 0; }

It generates the following HTML code:.gist table { margin-bottom: 0; }

This looks pretty simple, right. You can actaully reproduce an HTML scructure document using only PowerShell syntax.This is a pretty straight forward example, on some of the most basic HTML tags. But, the PSHTML module actually comes with (almost) all the HTML Tags available.Now, the big advantage of this, is as this is the PowerShell language, you benefit from all the ‘syntaxic’  confort of the language. This means, that PSHTML integrates very nicley with any of the powershell operators, loops etc…In the following example, we created listed all our favorite languages, by creating an array and looping through it using a foreach ..gist table { margin-bottom: 0; }

Generates:.gist table { margin-bottom: 0; }

But that’s not all. I have also built in a ‘templating’ mechanism, where you could create your header and footer once, and re-use on all your pages, as in the example below:.gist table { margin-bottom: 0; }

Assiming that body/footer are files located in /templates/body.ps1 | /templates/Footer.ps1.gist table { margin-bottom: 0; }

Generates:.gist table { margin-bottom: 0; }

I invite you to read more about the PSHTML project, by heading to the repository hosted on github.

Go to Top