BTE - The Bash Template Engine

Author: Adrian Perez <aperez@igalia.com>
License:GPL3

Abstract

Inert template engine for use in shell code. Provides text templating facilities, in such a way that it is not possible to run arbitrary code from a template: templates are parsed instead of passed along to the shell as code, or being expanded by means of the eval builtin.

Contents

Introduction

Warning

Documentation not yet available.

Functions

bte_format_xmlescape

bte_format_xmlescape state < input > output

Formatter which escapes characters into X(HT)ML entities. Currently the following characters are escaped:

Character Entity
< &lt;
> &gt;
& &amp;
' &apos;
" &quot;

bte_format_calc

bte_format_calc state < input > output

Performs simple arithmetic evaluations using a Bash built-in $((...)) expression. This allows for some degree of simple calculations. The usual +, -, * and / operands are allowed. Referring to Bash special variables like $RANDOM must be done without the dollar sign, and variables from the current state must be enclosed into square brackets. Spaces in the expression are not allowed, but grouping parentheses are. Example:

${(RANDOM+$[x])/3:calc}

bte_format_expand

bte_format_expand state < input > output

bte_dotted_var

bte_dotted_var state var

bte_template

bte_template state < input > output