github TekWizely/bash-tpl v0.7.0
Core Logic Re-Write; A Few Breaking Changes - v0.7.0

latest release: v0.7.1
18 months ago

Bash-TPL

A Smart, Lightweight shell script templating engine, written in Bash.

Release - v0.7.0

This is mostly an internal update, working to simplify the indentation-tracking logic, while also making it more accurate.

The result is code that is easier to understand and also hopefully easier to enhance in the future.

It does also have the benefit of reducing the total script size by about 60 lines.

Full Changelog: v0.6.0...v0.7.0

Breaking Changes

Although targeted as an internal update, it does introduce several breaking changes:

Printf Indentation

Given the following input file:

test.tpl

one
	two
		three
	four
five

The previous versions would generate the following script:

printf "%s\n" one
	printf "%s\n" $'\ttwo'
		printf "%s\n" $'\t\tthree'
	printf "%s\n" $'\tfour'
printf "%s\n" five

Having the indentation of the printf match the indentation of the text seemed like a useful feature that would provide added context to the user when reviewing/debugging the script.

User feedback suggested that the opposite was true; That the added indentation made reviewing the script more difficult.

So this version makes the indentation of the printf statements more predictable.

printf "%s\n" one
printf "%s\n" $'\ttwo'
printf "%s\n" $'\t\tthree'
printf "%s\n" $'\tfour'
printf "%s\n" five

Missing Stmt-Block Close

In this new version, and un-closed stmt-block will generate an error:

test.tpl

%
    echo "Hello, world"

compile

$ bash-tpl test.tpl

Error: Missing stmt-block close ('%')

Un-Balanced Stmt-Block Close

In this new version, an error is generated if the stmt-block close does not have the same indentation as the stmt-block open:

test.tpl

    %
        echo "Hello, world"
  %

compile

$ bash-tpl test.tpl

Error: stmt-block close indentation does not match open

Un-Indented Stmt-Block Content

Regarding the following template, which contains stmt-block lines which are not indented beyond the stmt-block start:

test.tpl

  %
   #1
  #2
 #3
#4
  %

Since bash-tpl encourages you to utilize indentation, not-doing so results in "undefined" behavior.

Thats still true in spirit, but this release tries to make the resulting output a bit more predictable.

That is, it tries to make the output match the input, by ignoring the stmt-block indentation and disabling indentation-correction:

output

   #1
  #2
 #3
#4

Empty-Line In == Empty Line Out

This is actually more of a bug fix.

Previously, some scenarios could result in leading whitespace on a line that was indented to be empty.

This version tries harder to ensure that an empty line in your input templates yields an appropriately empty line in the output.

Don't miss a new bash-tpl release

NewReleases is sending notifications on new releases.