Name

cx:pebble — Expands Pebble templates.

Synopsis

This step processes input with the Pebble templating engine.

Input portPrimarySequenceContent types
source✔   
Output portPrimarySequenceContent types
result✔   
Option nameTypeDefault valueRequired
contextmap(xs:string,item()) ✔ 
autoEscapingxs:booleantrue() 
defaultEscapingStrategyxs:string?() 
defaultLocalexs:string?() 
literalDecimalTreatedAsIntegerxs:boolean?() 
literalNumbersAsBigDecimalsxs:boolean?() 
maxRenderedSizexs:integer?() 
newlineTrimmingxs:booleantrue() 
prefixxs:string?() 
strictVariablesxs:booleanfalse() 
This is an extension step; to use it, your pipeline must include its declaration. For example, by including the extension library with an import at the top of your pipeline:
<p:import href="https://xmlcalabash.com/ext/library/pebble.xpl"/>
Declaration
 1 |<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
   |                xmlns:p="http://www.w3.org/ns/xproc"
   |                type="cx:pebble">
   |   <p:input port="source"/>
 5 |   <p:output port="result"/>
   |   <p:option name="context" as="map(xs:string,item())" required="true"/>
   |   <p:option name="prefix" as="xs:string?"/>
   |   <p:option name="defaultLocale" as="xs:string?"/>
   |   <p:option name="strictVariables" as="xs:boolean" select="false()"/>
10 |   <p:option name="literalDecimalTreatedAsInteger" as="xs:boolean?"/>
   |   <p:option name="literalNumbersAsBigDecimals" as="xs:boolean?"/>
   |   <p:option name="maxRenderedSize" as="xs:integer?"/>
   |   <p:option name="newlineTrimming" as="xs:boolean" select="true()"/>
   |   <p:option name="autoEscaping" as="xs:boolean" select="true()"/>
15 |   <p:option name="defaultEscapingStrategy" as="xs:string?"/>
   |</p:declare-step>

Description

This step processes the input document with the Pebble templating engine. Pebble templates operate on text documents. If the source is XML, HTML, XHTML, JSON, YAML, or TOML, it is serialized, processed with Pebble, and then re-parsed.

The options are all passed to the Pebble engine.

context

The map of name/value pairs used during expansion.

autoEscaping

Escape potentially unsafe data?

defaultEscapingStrategy

Select an escaping strategy: html, js, css, or url_param.

defaultLocale

The default locale for templates.

literalDecimalTreatedAsInteger

Treat decimals as integers (instead of longs).

literalNumbersAsBigDecimals

Treat literal numbers as big decimals.

maxRenderedSize

Maximum rendered size of the output. The step will fail if this threshold is exceeded.

newlineTrimming

By default, the Pebble template engine trims a newline that immediately follows a Pebble tag. If this option is false(), all newlines are preserved.

prefix

Filename prefix used when loading external templates.

strictVariables

If true, reference to a variable name that doesn’t exist will cause the step to fail. If false, the reference is replaced by the empty string.

Document properties

All document properties are preserved.