Bash-TPL
A Smart, Lightweight shell script templating engine, written in Bash.
Release - v0.6.0
feat: Text lines within Statement Blocks
This release introduces the ability to easily insert text lines within statement block bodies, without having close/re-open the blocks.
previously.tpl
%
# ...
if (condition); then
%
condition text ...
%
else
%
else text ...
%
fi
# ...
%
now.tpl
%
# ...
if (condition); then
% condition text ...
else
% else text ...
fi
# ...
%
NOTES:
- The indentation of the printed text lines will always match that of the statement block start tag
- This is to encourage you to format your text lines within the context of your script
- All whitespce after the text line tag (
'%
') will be printed as-as
Better-Formatted Scripts
In addition to being less-verbose, the generated scrips are also formatted better:
previously.sh
# ...
if (condition); then
printf "%s\n" condition\ text\ ...
else
printf "%s\n" else\ text\ ...
fi
# ...
now.sh
# ...
if (condition); then
printf "%s\n" condition\ text\ ...
else
printf "%s\n" else\ text\ ...
fi
# ...
bug: Indentation not tacked if first line of statement block not indented
There's been a long-standing bug where indentation tracking within statement blocks is not accurate if the first line of the block is not indented.
Essentially, bash-tpl was using the first line as the basis indentation tracking for the block, which broke down if that first line was not actually indented.
Now, the code keep searching for the first indented line, and uses that line as the basis.
This should provide more consistent behavior to otherwise well-indented scripts in the case where the first line of the block happens to not be indented.
Breaking Change
Due to the possible changes in leading whitespace in template output, this is considered a breaking change.
Full ChangeLog
Full Changelog: v0.5.0...v0.6.0