Use Python's Built-In Template Strings To Generate Output
Code
=
=
=
=
Results
The value is: quick fox
This is a basic one where you pass it two paths and a data dictionary and it makes the output.
Code
=
And here's a full boiler plate:
Code
=
=
return
=
** TL;DR
Create a template file named `template.txt` 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
Results
this is the name: Karl
and the color: Green
** From A String
Code
=
=
Results
Name: Karl - Color: Green
#+REFERENCES:
docs: https://docs.python.org/3/library/string.html#template-strings