rendering html from monad
I've just started dabbling with monad (aka "Windows Powershell"), so I tried porting my code for 'rendering HTML from irb' to it. It turns out to be a pretty good task for getting to know a new REPL environment.
Just for the record, this is what I came up with:
function Show-HTML ([string]$html) {
$ie=New-Object -ComObject InternetExplorer.Application
$ie.menubar=0
$ie.toolbar=0
$ie.statusbar=0
$ie.navigate("about:blank")
$ie.document.write($html)
$html=[string]$input
$ie.document.write($html)
$ie.visible="true"
}
You can either pass a string param, as in Show-Html "Hello World!", or you can pipe HTML in. Monad also has a nifty builtin called 'ConvertTo-HTML' which pretty much does what it says. So in order to get the same HTML table of environment variables from the irb example, you could use
dir Env: | ConvertTo-HTML Name,Value | Show-HTML
Comments
PSMDTAG:FAQ: How can I show HTML?
PSMDTAG:TYPE:COM: InternetExplorer.Application
Jeffrey Snover [MSFT]
Windows PowerShell/Aspen Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
Posted by: Jeffrey Snover | July 15, 2006 12:36 AM