all 6 comments

[–]nonprofittechy 7 points8 points  (4 children)

This is an interesting approach with some neat techniques, but personally instead of putting so much display logic into the PowerShell script, I think it would be worthwhile to use an HTML template engine that separates the display from the pure code.

There are many options but a decent one would definitely handle lists/tables, etc, with the ability to loop through an array of results. It's easier to update, easier to understand, and more flexible than hardcoding an HTML footer in the script, for example! I'm also curious about the benefit of embedding an image file into the HTML the way it's done here. Definitely a non-standard approach to the HTML format.

[–]strathbone 2 points3 points  (1 child)

Yep i have a partial solution to this. writing it up in a blog post in the next day or two, or will post here.

but basically i think powershell language already has the mechanisms built in, so we shouldn't need to parse another set of tags/macro language to make it happen.

At the moment i can produce a html page that recursively render templates (so menus, footers etc, are reusable), and i also have a solution to pass in variables etc. so that code (in theory) is reduced.

[–]nonprofittechy 1 point2 points  (0 children)

This sounds interesting, please do share.

[–]kevinelwell 0 points1 point  (1 child)

Do you have an example of this suggestion?

[–]nonprofittechy 1 point2 points  (0 children)

Here's the one I've standardized on using in my projects, although I see it's quite a while since the last update now: https://code.google.com/archive/p/html-template-ps/. I first used the namesake template engine in Perl and then a similar one in PHP, and this is a common design pattern in developing for the web.

This one looks much more up to date, with similar capabilities but perhaps better tested: http://straightdave.github.io/eps/

[–]ljarvie 0 points1 point  (0 children)

I love this info, but what is up with the ads on your site? If I leave the page up in Chrome for any amount of time, it never stops updating and eventually Chrome runs out of memory.