dig c21567f507 | ||
---|---|---|
.. | ||
README.md | ||
shtpl | ||
test.sh | ||
test.shtpl |
README.md
shtpl
sh templating
Install
Put the shtpl
script somewhere meant for executable scripts like ~/bin/shtpl
.
Make it executable: chmod +x shtpl
.
Usage
Create a template file to be executed with shtpl:
nano someTpl.shtpl
#!/path/to/shtpl
Hello $WHO !
chmod +x someTpl.shtpl
WHO=Doctor someTpl.shtpl
> Hello Doctor !
Templating syntax
shtpl uses a hack to turn you file into a call of echo "<your file here>"
, so it is simple, all what your system is able to understand as substitution is valid !
#!/path/to/shtpl
Simple variable: $ENV_VAR , and with brackets: ${TOTO}cm²
Sub commands: $(echo ok)
Prompt user input in place: $(read -r -p Type\ some\ text\ : v;echo $v)
Loops: $(
for ((i=0 ; $MAX_LOOP - $i ; i++))
do
echo $i
done
)
Call sub templates: $(VAR_TO_PASS=$SOME_VAR ./myOtherTemplate.shtpl)