diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/template.source.sh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/template.source.sh b/lib/template.source.sh index 5a7f023..5d9e4c1 100644 --- a/lib/template.source.sh +++ b/lib/template.source.sh @@ -28,7 +28,10 @@ template::_generate_file () { cd "$tpl_dir" || log PANIC "Unable to chdir to $tpl_dir" log INFO "Generating $tpl_path -> $dest" - export CURRENT_GMI="$dest" # Environt var can be used by .gmi.tpl + # Environment variables can be used from .gmi.tpl files + export CURRENT_TPL="$tpl_path" + export CURRENT_GMI="$dest" + template::_generate < "$tpl" > "$dest.tmp" mv "$dest.tmp" "$dest" log INFO "Done generating $dest" @@ -87,6 +90,14 @@ template::inline::index () { done | sort | uniq } +# To generate a table of contents +template::inline::toc () { + echo '```' + echo 'Table of contents:' + $GREP '^#' "$(basename "$CURRENT_TPL")" | $SED 's/#/ /g; s/^ //;' + echo '```' +} + template::test () { assert::equals "$(template::_line '<< echo -n foo')" 'foo' assert::equals "$(template::_line '<< echo foo')" 'foo' |
