Created
July 20, 2017 18:30
-
-
Save wgross/0fba55944d05747d2b1bf01d4d25ebd5 to your computer and use it in GitHub Desktop.
powershell html generator syntax experiment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Xml.Linq | |
@( | |
"html" | |
"head" | |
"body" | |
)|Foreach-Object -Process { | |
@" | |
function global:$_ { | |
[CmdletBinding()] | |
param( | |
[Parameter(ValueFromPipeline)] | |
`$ContentPipe, | |
[Parameter(Position=0)] | |
[scriptblock]`$ContentBlock | |
) | |
begin { | |
"<$_>"|Write-Output | |
} | |
process { | |
if(`$ContentBlock) { | |
`$ContentBlock.InvokeReturnAsIs()|Write-Output | |
} | |
`$ContentPipe | Write-Output | |
} | |
end { | |
"</$_>"|Write-Output | |
} | |
} | |
"@|Invoke-Expression | |
} | |
$data = (html { | |
"blah"|head | |
"zumsel"|body | |
}) | |
$data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment