diff --git a/shtpl/README.md b/shtpl/README.md index dd0efb2..661815e 100644 --- a/shtpl/README.md +++ b/shtpl/README.md @@ -1,5 +1,5 @@ # shtpl -#### sh templating +> sh templating ## Install @@ -10,4 +10,39 @@ Make it executable: `chmod +x shtpl`. Create a template file to be executed with shtpl: -`nano someTpl.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 ""`, 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) +``` \ No newline at end of file