Add python-script example
This commit is contained in:
parent
7c22d25501
commit
4712e4b09e
44
README.md
44
README.md
@ -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
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
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
|
Loading…
x
Reference in New Issue
Block a user