Receiving Template Parts Before Combining Them
In this lesson, the settings audit needs to keep each value as a value. The settings are flat, and
level is the number 2.
In Python, the audit helper takes one string, built with an f-string. Python fills it in before the call:
def audit(text):
print("audit:", text)
level = 2
audit(f"level={level}")
So the log shows audit: level=2, and the 2 is now plain text:
audit: level=2
Template literals work like f-strings, minus format specs such as :.2f, with a dollar sign before
each pair of braces. Called with parentheses, audit() gets the combined string, as in Python. Put
its name right before the backtick instead, and JavaScript calls it with the template itself: a
tagged template, with audit as its tag.
To keep the 2 a value, the port makes audit the tag but keeps Python’s one text parameter and
logs it. level is a constant, and the last line tags the template: