Add python-script example

This commit is contained in:
Chris Penner 2017-04-29 16:53:01 -06:00
parent 7c22d25501
commit 4712e4b09e
3 changed files with 58 additions and 0 deletions

@ -82,6 +82,10 @@ $ ./test.txt
interpolate that
```
Shell not powerful enough for you? No problem! Use all your favourite languages and
tools; See the FAQ or examples to see how to integrate with scripts (spoilers, just call them like you do in bash!)
[**Examples Here**](https://github.com/ChrisPenner/tempered/tree/master/examples)
Installation
@ -150,6 +154,46 @@ done }}
97 bottles of beer on the wall
```
### Other Scripts/Tools?
Duh! Interpolation works like a shell, just call the scripts or binaries you want!
Here we'll use a simple python script to spice things up!
```python
# favourites.py
import sys
print(" and ".join(sys.argv[1:]) + ",")
print("These are a few of my favourite things")
```
```
# My Favourite Things
{{ python favourites.py Gumdrops Roses Whiskers Kittens }}
When the dog bites
When the bee stings
When I'm feeling sad
I simply remember my favourite things
And then I don't feel so bad
```
Output:
```
# My Favourite Things
Gumdrops and Roses and Whiskers and Kittens,
These are a few of my favourite things
When the dog bites
When the bee stings
When I'm feeling sad
I simply remember my favourite things
And then I don't feel so bad
```
### \_\_: command not found?
Chances are you're forgetting to echo an env-var;

5
examples/favourites.py Normal file

@ -0,0 +1,5 @@
# You can write scripts in any language you like to level up your templates!
import sys
print(" and ".join(sys.argv[1:]) + ",")
print("These are a few of my favourite things")

9
examples/use-scripts.md Normal file

@ -0,0 +1,9 @@
# My Favourite Things
{{ python favourites.py Gumdrops Roses Whiskers Kittens }}
When the dog bites
When the bee stings
When I'm feeling sad
I simply remember my favourite things
And then I don't feel so bad