====== Step Operation - Template ====== ===== Template ===== ''template'' is an [[docs:flow:intermediate|intermediate step]] that creates a [[docs:resource:resource|data resource]] from a [[docs:templating:template|template]]. The ''template'': * accepts one or several [[docs:resource:record|record]] of a [[docs:resource:content|content data resource]] as [[docs:flow:source|source]] * and creates a [[docs:resource:resource|data resource]] as [[docs:flow:target|output]]. ===== Arguments ===== The ''template'' operations accept the following arguments. * ''template-selectors'' - a list of [[docs:resource:data_selector|data selectors]] that selects ''templates'' data resources. * ''template-inline'' - a inline template with the following properties: * ''logical-name'': the [[docs:resource:logicalname|logicalName]] (used to match the template to a [[docs:flow:source|source data resource]]) * ''type'': the [[docs:resource:type|mediaType type]] of the template * ''content'': the template text * ''template-email'': define if an html template is an email template. It defaults to false, if true, the css rules will be in-lined for html template. If you use bootstrap, the [[https://bootstrapemail.com/docs/introduction|bootstrap email css]] stylesheet is used instead. * ''engine'' - the [[#engine|templating engine]] (default to ''native'') * ''step-granularity'': defines the [[docs:flow:granularity|granularity of the execution]] * [[docs:resource:record|record]]: the template will be processed for each record (default) * [[docs:resource:resource|resource]]: the template will be processed on all records (only available for a json template) * ''table-variables'': template variables that defines tabular data. A map of: * ''name'': a variable name * ''selectors'': a [[docs:resource:data_selector|data selector]] * ''parameters'': a map of SQL parameters applied to the selected [[docs:resource:query|data query resources]] * ''name'': the parameter name * ''value'': the parameter value (you can reference value of the input data using the ''$'' sign) * ''output-logical-name'': a pattern that defines the logical name of: * the resources (for a template output) * or of the columns (for a extended-records) * ''output'': * ''templates'': the templates output * ''extended-records'': the source records with extra columns that stores the templates output ==== Engine ==== The ''engine'' is the process that is responsible to transform a template in a document. ''Tabulify'' supports the following value as ''engine'': * ''native'' (default) - the [[docs:templating:native|built-in tabulify engine]] * ''thymeleaf'' - the [[docs:templating:thymeleaf|the thymeleaf engine]] (natural template) * ''pebble'' - the [[docs:templating:pebble|pebble engine]] (ninja syntax) ==== Type ==== ''type'' is the [[docs:templating:template#type|media type of the template]]. The type default to the type of the template. ==== Template Match ==== If the operation has: * only one template defined, the template will be applied to all [[docs:flow:source|source data resource]]. * several templates defined, the template will be the template that has the same [[docs:resource:logicalname|logicalName]] than the [[docs:flow:source|source data resource]] ===== Syntax ===== This operation is a [[docs:flow:intermediate|intermediate pipeline operation]] * Template Selectors - name: "Json" op: "template" args: template-selectors: - pattern@connection - pattern2@connection2 * **Inline Json Template** - name: "Json" op: "template" args: template-inline: type: json content: | { "${group}": { "${item_code}": { "price": "${price}", "description": "${description}" } }