Researching some ways to generate a .tex file and subsequently a PDF, I found a beautiful pythonic method of string interpolation that I've never seen before, specifically in this SO question here:
import argparse
content = r'''\documentclass{article}
\begin{document}
... P \& B
\textbf{\huge %(school)s \\}
\vspace{1cm}
\textbf{\Large %(title)s \\}
...
\end{document}
'''
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--course')
parser.add_argument('-t', '--title')
parser.add_argument('-n', '--name',)
parser.add_argument('-s', '--school', default='My U')
args = parser.parse_args()
with open('cover.tex','w') as f:
f.write(content%args.__dict__) #This!
Is there any way of implementing the pythonic solution above in JavaScript?
$before the{}s to interpolate..?content = r'''\documentclass{article}toconst content = String.raw`\documentclass${article}and continue the pattern (the backslashes create problems)%(school)swas interpolated by the corresponding value of the key "school" inargs.__dict__. Are you saying that replacing%(school)with${school}works?$(varName}, as you showed in the original version of your question - that'll work just fine