Mettre à jour 'shtpl/README.md'

This commit is contained in:
dig 2018-10-09 17:22:17 +02:00
parent 2798853cf6
commit c21567f507
1 changed files with 37 additions and 2 deletions

View File

@ -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 "<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)
```