HorkerTemplateEngine.dll-Help.xml
<?xml version="1.0" encoding="utf-8"?>
<helpItems schema="maml" xmlns="http://msh"> <!-- Cmdlet: Invoke-TemplateEngine --> <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"> <command:details> <command:name>Invoke-TemplateEngine</command:name> <command:verb>Invoke</command:verb> <command:noun>TemplateEngine</command:noun> <maml:description> <maml:para>Process a PowerShell-based document template and generates a document dynamically.</maml:para> </maml:description> </command:details> <maml:description> <maml:para>Invoke-TemplateEngine processes a document template that embeds PowerShell scripts and generates a plain text as an outcome to the standard output stream.</maml:para> <maml:para>It recognizes text portions enclosed with <% and %> as PowerShell code snippets and executes them. The objects returned by the code into the standard output stream are written into a resultant document.</maml:para> <maml:para>Text portions enclosed with <% and- %> are processed as the same above, but the following newlines will not appear in the output.</maml:para> <maml:para>Note that, unlike usual PowerShell output, such objects are converted into strings by the ToString() method and no newlines are inserted between them. See Example section for details.</maml:para> </maml:description> <command:syntax> <!-- Parameter set: __AllParameterSets --> <command:syntaxItem> <maml:name>Invoke-TemplateEngine</maml:name> <!-- Parameter: Template --> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue)" position="0"> <maml:name>Template</maml:name> <maml:description> <maml:para>A document template, given as a string or an array of strings through pipeline.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: ProcessorFile --> <command:parameter required="false" globbing="false" pipelineInput="false" position="1"> <maml:name>ProcessorFile</maml:name> <maml:description> <maml:para>If specified, an internal script for processing will be saved into the file. (For debugging purpse)</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <!-- Parameter: Template --> <command:parameter required="true" globbing="false" pipelineInput="true (ByValue)" position="0"> <maml:name>Template</maml:name> <maml:description> <maml:para>A document template, given as a string or an array of strings through pipeline.</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> </command:parameter> <!-- Parameter: ProcessorFile --> <command:parameter required="false" globbing="false" pipelineInput="false" position="1"> <maml:name>ProcessorFile</maml:name> <maml:description> <maml:para>If specified, an internal script for processing will be saved into the file. (For debugging purpse)</maml:para> </maml:description> <command:parameterValue required="true">string</command:parameterValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> </dev:type> <maml:description> <maml:para>A document template, given as a string or an array of strings through pipeline.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues /> <command:examples> <command:example> <maml:title>---------- EXAMPLE 1 ----------</maml:title> <dev:code>PS>Get-Content template.txt Dear <% $customer %>, This is a mail for you. PS> PS>$customer = "Bill" PS>Get-Content template.txt | Invoke-TemplateEngine Dear Bill, This is a mail for you. PS> </dev:code> </command:example> <command:example> <maml:title>---------- EXAMPLE 2 ----------</maml:title> <dev:code>PS>Invoke-TemplateEngine '<% foreach ($i in 1..3) { $i } %>' 123</dev:code> <dev:remarks> <maml:para>The object returned from the script are written into the output without any gaps. To control spaces or newlines between them, see the next example.</maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 3 ----------</maml:title> <dev:code>PS>Get-Content template.txt <% foreach ($i in 1..3) { -%> <% $i %> <% } -%> PS> PS>Get-Content template.txt | Invoke-TemplateEngine 1 2 3</dev:code> <dev:remarks> <maml:para>When '-%>' is used as a closing tag, a following newline of a code block will not appear in the output.</maml:para> <maml:para></maml:para> </dev:remarks> </command:example> <command:example> <maml:title>---------- EXAMPLE 4 ----------</maml:title> <dev:code>PS>dir C:\work Directory: C:\work Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2017/12/29 17:36 252 a.txt -a---- 2017/12/29 17:36 252 b.txt -a---- 2017/12/29 17:36 252 c.txt PS>##### Objects are stringified by the ToString() method. PS> PS>Invoke-TemplateEngine '<% dir %>' a.textb.txtc.txt PS> PS>##### Specify a property name to manage output format PS> PS>Invoke-TemplateEngine '<% (dir).FullName -join "`r`n" %>' C:\work\a.txt C:\work\b.txt C:\work\c.txt PS> PS>##### Format-Table and Out-String enable to generate host-like output. PS> PS>Invoke-TemplateEngine '<% dir | ft -auto | out-string %>' Directory: C:\work Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2017/12/29 17:36 252 a.txt -a---- 2017/12/29 17:36 252 b.txt -a---- 2017/12/29 17:36 252 c.txt</dev:code> </command:example> </command:examples> </command:command> </helpItems> |