Specify the data parser
Direct specification of data parser
-r, --parser: Defines the parser to use when the source data is provided through the console. Accepted values areyaml,json,xml,url,FrontMatterorFrontMatterMarkdown. This option is required only when the--sourceargument is omitted or if the extension of the source file is not recognized to determine the parser. For multiple sources, this option applies to all files, regardless of their extensions or any pre-assigned engine associations.
didot -t template.hbs -s data.txt -r json -o output.txt
In this example:
template.hbsis the Handlebars template file.data.txtis the source file.jsonis the parser of input data from the source file.output.txtis the file where the output will be rendered.
Add or replace extension associations for data parsers
-X, --parser-extension: Defines the association of a file’s extension with a parser. More than one association can be specified.
didot -t template.txt -s data.json -X dat:Json;fm:FrontMatter -o output.txt
In this example:
template.txtis the template file.data.jsonis the data JSON file.dat:Json;fm:FrontMatteris associating JSON to the extension.datand FrontMatter to the extension.fm.output.txtis the file where the output will be rendered.
By default following file’s extension association are registered:
.jsonto JSON.yamlto YAML.ymlto YAML.xmlto XML.mdto FrontMatterMarkdown
Specify the template engine
Direct specification of template engine
-e, --engine: Defines the template engine to use independantly of the template file extension. Accepted values arescriban,dotliquid,fluid,handlebars,stringtemplate,smartformat.
didot -t template.txt -s data.json -e handlebars -o output.txt
In this example:
template.txtis the template file.data.jsonis the data JSON file.handlebarsis the template engine to use.output.txtis the file where the output will be rendered.
Add or replace extension associations for template engines
-x, --engine-extension: Defines the association of a file’s extension with a template engine. More than one can be specified.
didot -t template.txt -s data.json -x txt:handlebars;liquid:fluid -o output.txt
In this example:
template.txtis the template file.data.jsonis the data JSON file.txt:handlebars;liquid:fluidis associating Handlbars to the extension.txtand Fluid to the extension.liquid.output.txtis the file where the output will be rendered.
By default following file’s extension association are registered:
.scribanto Scriban.liquidto DotLiquid.hbsto Handlebars.smartto SmartFormat.stand.stgto StringTemplate