Use Python's Built - In Template Strings To Generate Output
=
=
=
=
This is a basic one where you pass it two paths and a data dictionary and it makes the output.
=
And here's a full boiler plate :
=
=
return
=
** TL;DR
Create a template file named [TODO: Code shorthand span ] like this :
#+BLOCKNAME : template.txt #+begin _ src shell : tangle ~/Grimoire/ _ examples/template.txt
this is the name : $name and the color : $color
#+end _ src
Then make this
#+BLOCKNAME : generator.py #+begin _ src python : results output : dir ~/Grimoire/ _ examples : wrap example : post padder(data=*this*)
from string import Template
with open('template.txt') as _ tmpl : template = Template( _ tmpl.read()) output = template.substitute( name="Karl", color="Green" ) print(output)
#+end _ src
** From A String
=
=
results start
#+REFERENCES :
docs : https : //docs.python.org/3/library/string.html#template - strings