3 ms·
In Python, I've always used string substitution. I've never understood the need for a special templating system when it's already built into the language:
by jackalope 14y ago
In Python, I've always used string substitution. I've never understood the need for a special templating system when it's already built into the language:
template = """<boilerplate html>%(greeting)s</boilerplate html>"""
parts = {'greeting': "Hello, World!"}
page = template % parts
I create my site-wide template in a module and never have to look at it again, so my application code is mostly logic. When I have to work on PHP or Coldfusion, I don't understand how people can bear to have the logic hidden in a markup language that's mixed up with another markup language. Many can't, and that's why there are templating engines for what are essentially template-based languages.