en-US/PSStringTemplate.dll-Help.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<?xml version="1.0" encoding="utf-8"?>
<helpItems schema="maml" xmlns="http://msh">
  <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
    <command:details>
      <command:name>Invoke-StringTemplate</command:name>
      <command:verb>Invoke</command:verb>
      <command:noun>StringTemplate</command:noun>
      <maml:description>
        <maml:para>Renders a Template object.</maml:para>
      </maml:description>
    </command:details>
    <maml:description>
      <maml:para>This cmdlet will take a Template object from a TemplateGroup, add specified parameters and render the template into a string. It can use an existing Template object (from the New-StringTemplateGroup cmdlet) or it can create a new Template using a string specified in the "Definition" parameter.</maml:para>
    </maml:description>
    <command:syntax>
      <command:syntaxItem>
        <maml:name>Invoke-StringTemplate</maml:name>
        <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none">
          <maml:name>Parameters</maml:name>
          <maml:Description>
            <maml:para>Specifies the arguments to pass to the template. If a IDictionary object (such as a hashtable) is specified, the entries will be used as arguments. All other objects will use the objects properties as arguments.</maml:para>
            <maml:para>Some methods will also be added as arguments if they meet the following criteria:</maml:para>
            <maml:para>- Has a return value</maml:para>
            <maml:para>- Has a parameterless overload</maml:para>
            <maml:para>- The name follows the format "GetSomething"</maml:para>
            <maml:para>- Does not have a matching property with value</maml:para>
            <maml:para></maml:para>
            <maml:para>As an example, the method RuntimeMethodInfo.GetParameters() would be added as an argument with the name "Parameters". This is to stay consistent with StringTemplate4 behavior. See documentation for the StringTemplate4 template engine more information.</maml:para>
          </maml:Description>
          <command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
          <dev:type>
            <maml:name>PSObject</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>None</dev:defaultValue>
        </command:parameter>
        <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
          <maml:name>Definition</maml:name>
          <maml:Description>
            <maml:para>Specifies a Template definition string to create a new Template to be rendered.</maml:para>
          </maml:Description>
          <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>None</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
      <command:syntaxItem>
        <maml:name>Invoke-StringTemplate</maml:name>
        <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none">
          <maml:name>Group</maml:name>
          <maml:Description>
            <maml:para>Specifies an existing TemplateGroup to retrieve a template from.</maml:para>
          </maml:Description>
          <command:parameterValue required="true" variableLength="false">TemplateGroupInfo</command:parameterValue>
          <dev:type>
            <maml:name>TemplateGroupInfo</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>None</dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none">
          <maml:name>Parameters</maml:name>
          <maml:Description>
            <maml:para>Specifies the arguments to pass to the template. If a IDictionary object (such as a hashtable) is specified, the entries will be used as arguments. All other objects will use the objects properties as arguments.</maml:para>
            <maml:para>Some methods will also be added as arguments if they meet the following criteria:</maml:para>
            <maml:para>- Has a return value</maml:para>
            <maml:para>- Has a parameterless overload</maml:para>
            <maml:para>- The name follows the format "GetSomething"</maml:para>
            <maml:para>- Does not have a matching property with value</maml:para>
            <maml:para></maml:para>
            <maml:para>As an example, the method RuntimeMethodInfo.GetParameters() would be added as an argument with the name "Parameters". This is to stay consistent with StringTemplate4 behavior. See documentation for the StringTemplate4 template engine more information.</maml:para>
          </maml:Description>
          <command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
          <dev:type>
            <maml:name>PSObject</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>None</dev:defaultValue>
        </command:parameter>
        <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="Name">
          <maml:name>Name</maml:name>
          <maml:Description>
            <maml:para>Specifies the name of the Template within the TemplateGroup.</maml:para>
          </maml:Description>
          <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>None</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
        <maml:name>Definition</maml:name>
        <maml:Description>
          <maml:para>Specifies a Template definition string to create a new Template to be rendered.</maml:para>
        </maml:Description>
        <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>None</dev:defaultValue>
      </command:parameter>
      <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName, ByValue)" position="0" aliases="none">
        <maml:name>Group</maml:name>
        <maml:Description>
          <maml:para>Specifies an existing TemplateGroup to retrieve a template from.</maml:para>
        </maml:Description>
        <command:parameterValue required="true" variableLength="false">TemplateGroupInfo</command:parameterValue>
        <dev:type>
          <maml:name>TemplateGroupInfo</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>None</dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="Name">
        <maml:name>Name</maml:name>
        <maml:Description>
          <maml:para>Specifies the name of the Template within the TemplateGroup.</maml:para>
        </maml:Description>
        <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>None</dev:defaultValue>
      </command:parameter>
      <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="0" aliases="none">
        <maml:name>Parameters</maml:name>
        <maml:Description>
          <maml:para>Specifies the arguments to pass to the template. If a IDictionary object (such as a hashtable) is specified, the entries will be used as arguments. All other objects will use the objects properties as arguments.</maml:para>
          <maml:para>Some methods will also be added as arguments if they meet the following criteria:</maml:para>
          <maml:para>- Has a return value</maml:para>
          <maml:para>- Has a parameterless overload</maml:para>
          <maml:para>- The name follows the format "GetSomething"</maml:para>
          <maml:para>- Does not have a matching property with value</maml:para>
          <maml:para></maml:para>
          <maml:para>As an example, the method RuntimeMethodInfo.GetParameters() would be added as an argument with the name "Parameters". This is to stay consistent with StringTemplate4 behavior. See documentation for the StringTemplate4 template engine more information.</maml:para>
        </maml:Description>
        <command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
        <dev:type>
          <maml:name>PSObject</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>None</dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:inputTypes>
      <command:inputType>
        <dev:type>
          <maml:name>PSStringTemplate.TemplateGroupInfo</maml:name>
        </dev:type>
        <maml:description>
          <maml:para>You can pass template groups from New-StringTemplateGroup to this cmdlet. You can also pass objects with a property named "Group".</maml:para>
        </maml:description>
      </command:inputType>
      <command:inputType>
        <dev:type>
          <maml:name>System.String</maml:name>
        </dev:type>
        <maml:description>
          <maml:para>You can pass objects with a property named "Name" as template names to this cmdlet.</maml:para>
        </maml:description>
      </command:inputType>
    </command:inputTypes>
    <command:returnValues>
      <command:returnValue>
        <dev:type>
          <maml:name>System.String</maml:name>
        </dev:type>
        <maml:description>
          <maml:para>The rendered template will be returned as a string.</maml:para>
        </maml:description>
      </command:returnValue>
    </command:returnValues>
    <maml:alertSet>
      <maml:alert>
        <maml:para></maml:para>
      </maml:alert>
    </maml:alertSet>
    <command:examples>
      <command:example>
        <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
        <dev:code>PS&gt; Invoke-StringTemplate -Definition '&lt;language&gt; is very &lt;adjective&gt;!' -Parameters @{
    language = 'PowerShell'
    adjective = 'cool'
}
 
Output
------
 
PowerShell is very cool!</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
        <dev:code>PS&gt; $definition = 'Name: &lt;Name&gt;&lt;\n&gt;Commands: &lt;ExportedCommands; separator=", "&gt;'
PS&gt; Invoke-StringTemplate -Definition $definition -Parameters (Get-Module PSReadLine)
 
Output
------
 
Name: PSReadline
Commands: Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Set-PSReadlineOption, PSConsoleHostReadline</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
      <command:example>
        <maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title>
        <dev:code>PS&gt; $definition = @'
    Param(parameter) ::= "[&lt;parameter.ParameterType.Name&gt;] $&lt;parameter.Name&gt;"
    Method(member) ::= &lt;&lt;
[&lt;member.ReturnType.Name&gt;]&lt;if(member.IsStatic)&gt; static&lt;endif&gt; &lt;member.Name&gt; (&lt;member.Parameters:Param(); separator=", "&gt;) {
    throw [NotImplementedException]::new()
}
&gt;&gt;
    Class(Name, DeclaredMethods) ::= &lt;&lt;
class MyClass : &lt;Name&gt; {
    &lt;DeclaredMethods:Method(); separator="\n\n"&gt;
}
&gt;&gt;
'@
PS&gt; $group = New-StringTemplateGroup -Definition $definition
PS&gt; $group | Invoke-StringTemplate -Name Class -Parameters ([System.Runtime.InteropServices.ICustomMarshaler])
 
Output
------
 
class MyClass : ICustomMarshaler {
    [Object] MarshalNativeToManaged ([IntPtr] $pNativeData) {
        throw [NotImplementedException]::new()
    }
 
    [IntPtr] MarshalManagedToNative ([Object] $ManagedObj) {
        throw [NotImplementedException]::new()
    }
 
    [Void] CleanUpNativeData ([IntPtr] $pNativeData) {
        throw [NotImplementedException]::new()
    }
 
    [Void] CleanUpManagedData ([Object] $ManagedObj) {
        throw [NotImplementedException]::new()
    }
 
    [Int32] GetNativeDataSize () {
        throw [NotImplementedException]::new()
    }
}</dev:code>
        <dev:remarks>
          <maml:para></maml:para>
        </dev:remarks>
      </command:example>
    </command:examples>
    <command:relatedLinks>
      <maml:navigationLink>
        <maml:linkText>Online Version:</maml:linkText>
        <maml:uri>https://github.com/SeeminglyScience/PSStringTemplate/blob/master/docs/en-US/Invoke-StringTemplate.md</maml:uri>
      </maml:navigationLink>
    </command:relatedLinks>
  </command:command>
  <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
    <command:details>
      <command:name>New-StringTemplateGroup</command:name>
      <command:verb>New</command:verb>
      <command:noun>StringTemplateGroup</command:noun>
      <maml:description>
        <maml:para>Define a group of templates.</maml:para>
      </maml:description>
    </command:details>
    <maml:description>
      <maml:para>The New-StringTemplateGroup cmdlet allows you to create a group of templates using the group definition syntax. Templates within a group can reference other templates in the same group.</maml:para>
      <maml:para>You can use this to enumerate arrays, call different templates based on conditions, or just for better organization.</maml:para>
    </maml:description>
    <command:syntax>
      <command:syntaxItem>
        <maml:name>New-StringTemplateGroup</maml:name>
        <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
          <maml:name>Definition</maml:name>
          <maml:Description>
            <maml:para>The group definition string to use to compile a template group.</maml:para>
          </maml:Description>
          <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
          <dev:type>
            <maml:name>String</maml:name>
            <maml:uri />
          </dev:type>
          <dev:defaultValue>None</dev:defaultValue>
        </command:parameter>
      </command:syntaxItem>
    </command:syntax>
    <command:parameters>
      <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
        <maml:name>Definition</maml:name>
        <maml:Description>
          <maml:para>The group definition string to use to compile a template group.</maml:para>
        </maml:Description>
        <command:parameterValue required="true" variableLength="false">String</command:parameterValue>
        <dev:type>
          <maml:name>String</maml:name>
          <maml:uri />
        </dev:type>
        <dev:defaultValue>None</dev:defaultValue>
      </command:parameter>
    </command:parameters>
    <command:inputTypes>
      <command:inputType>
        <dev:type>
          <maml:name>None</maml:name>
        </dev:type>
        <maml:description>
          <maml:para></maml:para>
        </maml:description>
      </command:inputType>
    </command:inputTypes>
    <command:returnValues>
      <command:returnValue>
        <dev:type>
          <maml:name>PSStringTemplate.TemplateGroupInfo</maml:name>
        </dev:type>
        <maml:description>
          <maml:para>The compiled template group is returned to the pipeline. This can then be passed to the Invoke-StringTemplate cmdlet for rendering.</maml:para>
        </maml:description>
      </command:returnValue>
    </command:returnValues>
    <maml:alertSet>
      <maml:alert>
        <maml:para></maml:para>
      </maml:alert>
    </maml:alertSet>
    <command:examples>
      <command:example>
        <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
        <dev:code>PS&gt; $group = New-StringTemplateGroup -Definition @'
 
    memberTemplate(Name, Parameters, ReturnType) ::= &lt;&lt;
&lt;Name&gt;&lt;if(ReturnType)&gt;(&lt;Parameters:paramTemplate(); separator=", "&gt;)&lt;endif&gt;
&gt;&gt;
 
    paramTemplate(param) ::= "$&lt;param.Name&gt;"
'@
PS&gt; $group | Invoke-StringTemplate -Name memberTemplate ([string].GetProperty('Length'))
Length
PS&gt; $group | Invoke-StringTemplate -Name memberTemplate ([string].GetMethod('Clone'))
Clone()
PS&gt; $group | Invoke-StringTemplate -Name memberTemplate ([string].GetMethod('IsNullOrWhiteSpace'))
IsNullOrWhiteSpace($value)
PS&gt; $group | Invoke-StringTemplate -Name memberTemplate ([string].GetMethod('Insert'))
Insert($startIndex, $value)</dev:code>
        <dev:remarks>
          <maml:para>Create a template to generate different member expressions from MemberInfo objects.</maml:para>
        </dev:remarks>
      </command:example>
    </command:examples>
    <command:relatedLinks>
      <maml:navigationLink>
        <maml:linkText>Online Version:</maml:linkText>
        <maml:uri>https://github.com/SeeminglyScience/PSStringTemplate/blob/master/docs/en-US/New-StringTemplateGroup.md</maml:uri>
      </maml:navigationLink>
    </command:relatedLinks>
  </command:command>
</helpItems>