by oising
23. December 2008 21:16
Just to be completely silly, I thought I’d do a series of posts on CTP3 features themed around Christmas. Hmm. That might read better as a series of Christmas posts themed around CTP3. A very original idea I’m sure, but hey, those who know me will know that I never pass up the opportunity to make a bad joke. So, without further adieu:
On the first day of Christmas, Jeffrey gave to me:
Nested Here-Strings
Here-Strings can now be embedded within each other to make it even easier to construct literal documents! Delimit any nested code between $( and ) and then continue to use a nested string within that as if it was completely stand alone. It just works! Cool, eh?
- function Get-CommandDefinitionHtml {
-
-
-
- [CmdletBinding()]
- param(
- [ValidateNotNullOrEmpty()]
- [string]$name
- )
-
- $command = get-command $name
-
-
- $PSCmdlet.WriteVerbose("Dumping HTML for " + $command)
-
- @"
- <html>
- <head>
- <title>$($command.name)</title>
- </head>
- <body>
- <table border="1">
- $(
- $command.parametersets | % {
- @"
-
- <tr>
- <td>$($_.name)</td>
- <td>
- <table border="1">
- <tr>
- <th colspan="8">Parameters</th>
-
- $(
- $count = 0
- $_.parameters | % {
- if (0 -eq ($count % 8)) {
- @"
- </tr>
- <tr>
- "@
- }
- @"
- <td>$($_.name)</td>
- "@
- $count++
- }
- )
- </tr>
- </table>
- </td>
- </tr>
- "@
- }
- )
- </table>
- </body>
- </html>
- "@
- }
-
- Get-CommandDefinitionHtml get-item > out.html
-
-
- invoke-item out.html