Mustache Templating Example
SchemaCrawler integrates with Mustache to allow you to generate custom text output from your database schema using logic-less Mustache templates. Mustache’s simple {{variable}} and {{#section}} syntax makes it easy to produce clean, readable output in any text format.
How to Run
Before running this example, complete the setup in Getting Started.
- Create a file called “tables.mustache” with the contents shown below.
- Run the command:
schemacrawler \
--server postgresql \
--host postgresql \
--database schemacrawler \
--user schemacrawler \
--password schemacrawler \
--info-level standard \
--command template \
--templating-language=mustache \
--template share/tables.mustache \
--output-file share/output.txt
> PowerShell: Replace trailing backslashes (\) with backticks (`) for line continuation.
Replace with the connection options for your chosen database. See Getting Started.
The output file will appear in your current working directory on the host.
Resource Files
tables.mustache
{{&catalog.crawlInfo}}
{{#catalog.tables}}
- {{&fullName}}
{{#columns}}
- {{&name}}
{{/columns}}
{{/catalog.tables}}
Place this file in your working directory. It will be accessible inside the container as
share/tables.mustache.
How to Experiment
- Modify
tables.mustacheto change the output format — for example, produce Markdown, HTML, or CSV. - Pass a different
.mustachetemplate file via--template share/<filename>.mustacheto try alternate templates. - Use
{{&variable}}(triple-stash equivalent with&) for unescaped output, or{{variable}}for HTML-escaped output. - Adjust the
--info-levelflag (e.g.,detailedormaximum) in the script to expose more schema metadata to the template.