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 &lt;% and %&gt; 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 &lt;% and- %&gt; 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&gt;Get-Content template.txt
Dear &lt;% $customer %&gt;,
This is a mail for you.
PS&gt;
PS&gt;$customer = "Bill"
PS&gt;Get-Content template.txt | Invoke-TemplateEngine
Dear Bill,
This is a mail for you.
PS&gt; </dev:code>
      </command:example>
      <command:example>
        <maml:title>---------- EXAMPLE 2 ----------</maml:title>
        <dev:code>PS&gt;Invoke-TemplateEngine '&lt;% foreach ($i in 1..3) { $i } %&gt;'
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&gt;Get-Content template.txt
&lt;% foreach ($i in 1..3) { -%&gt;
&lt;% $i %&gt;
&lt;% } -%&gt;
PS&gt;
PS&gt;Get-Content template.txt | Invoke-TemplateEngine
1
2
3</dev:code>
        <dev:remarks>
          <maml:para>When '-%&gt;' 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&gt;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&gt;##### Objects are stringified by the ToString() method.
PS&gt;
PS&gt;Invoke-TemplateEngine '&lt;% dir %&gt;'
a.textb.txtc.txt
PS&gt;
PS&gt;##### Specify a property name to manage output format
PS&gt;
PS&gt;Invoke-TemplateEngine '&lt;% (dir).FullName -join "`r`n" %&gt;'
C:\work\a.txt
C:\work\b.txt
C:\work\c.txt
PS&gt;
PS&gt;##### Format-Table and Out-String enable to generate host-like output.
PS&gt;
PS&gt;Invoke-TemplateEngine '&lt;% dir | ft -auto | out-string %&gt;'
 
    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>