|
| 1 | +PS1XML.Template |
| 2 | +--------------- |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +### Synopsis |
| 8 | +PS1XML Template Transpiler. |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | + |
| 15 | +### Description |
| 16 | + |
| 17 | +Allows PipeScript to generate PS1XML. |
| 18 | + |
| 19 | +Multiline comments blocks like this ```<!--{}-->``` will be treated as blocks of PipeScript. |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | + |
| 26 | +### Examples |
| 27 | +#### EXAMPLE 1 |
| 28 | +```PowerShell |
| 29 | +$typesFile, $typeDefinition, $scriptMethod = Invoke-PipeScript { |
| 30 | +``` |
| 31 | +types.ps1xml template ' |
| 32 | + <Types> |
| 33 | + <!--{param([Alias("TypeDefinition")]$TypeDefinitions) $TypeDefinitions }--> |
| 34 | + </Types> |
| 35 | + ' |
| 36 | + |
| 37 | + typeDefinition.ps1xml template ' |
| 38 | + <Type> |
| 39 | + <!--{param([Alias("PSTypeName")]$TypeName) "<Name>$($typename)</Name>" }--> |
| 40 | + <!--{param([Alias("PSMembers","Member")]$Members) "<Members>$($members)</Members>" }--> |
| 41 | + </Type> |
| 42 | + ' |
| 43 | + |
| 44 | + scriptMethod.ps1xml template ' |
| 45 | + <ScriptMethod> |
| 46 | + <!--{param([Alias("Name")]$MethodName) "<Name>$($MethodName)</Name>" }--> |
| 47 | + <!--{param([ScriptBlock]$MethodDefinition) "<Script>$([Security.SecurityElement]::Escape("$MethodDefinition"))</Script>" }--> |
| 48 | + </ScriptMethod> |
| 49 | + ' |
| 50 | +} |
| 51 | + |
| 52 | + |
| 53 | +$typesFile.Save("Test.types.ps1xml", |
| 54 | + $typeDefinition.Evaluate(@{ |
| 55 | + TypeName='foobar' |
| 56 | + Members = |
| 57 | + @($scriptMethod.Evaluate( |
| 58 | + @{ |
| 59 | + MethodName = 'foo' |
| 60 | + MethodDefinition = {"foo"} |
| 61 | + } |
| 62 | + ),$scriptMethod.Evaluate( |
| 63 | + @{ |
| 64 | + MethodName = 'bar' |
| 65 | + MethodDefinition = {"bar"} |
| 66 | + } |
| 67 | + ),$scriptMethod.Evaluate( |
| 68 | + @{ |
| 69 | + MethodName = 'baz' |
| 70 | + MethodDefinition = {"baz"} |
| 71 | + } |
| 72 | + )) |
| 73 | + }) |
| 74 | +) |
| 75 | + |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | + |
| 80 | +### Parameters |
| 81 | +#### **CommandInfo** |
| 82 | + |
| 83 | +The command information. This will include the path to the file. |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +|Type |Required|Position|PipelineInput | |
| 91 | +|---------------|--------|--------|--------------| |
| 92 | +|`[CommandInfo]`|true |named |true (ByValue)| |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +#### **AsTemplateObject** |
| 97 | + |
| 98 | +If set, will return the information required to dynamically apply this template to any text. |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +|Type |Required|Position|PipelineInput| |
| 106 | +|----------|--------|--------|-------------| |
| 107 | +|`[Switch]`|true |named |false | |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +#### **Parameter** |
| 112 | + |
| 113 | +A dictionary of parameters. |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | +|Type |Required|Position|PipelineInput| |
| 121 | +|---------------|--------|--------|-------------| |
| 122 | +|`[IDictionary]`|false |named |false | |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | +#### **ArgumentList** |
| 127 | + |
| 128 | +A list of arguments. |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | +|Type |Required|Position|PipelineInput| |
| 136 | +|--------------|--------|--------|-------------| |
| 137 | +|`[PSObject[]]`|false |named |false | |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | + |
| 146 | +### Syntax |
| 147 | +```PowerShell |
| 148 | +PS1XML.Template -CommandInfo <CommandInfo> [-Parameter <IDictionary>] [-ArgumentList <PSObject[]>] [<CommonParameters>] |
| 149 | +``` |
| 150 | +```PowerShell |
| 151 | +PS1XML.Template -AsTemplateObject [-Parameter <IDictionary>] [-ArgumentList <PSObject[]>] [<CommonParameters>] |
| 152 | +``` |
0 commit comments