Skip to content

Instantly share code, notes, and snippets.

@kgn
Created December 15, 2010 20:15
Show Gist options
  • Save kgn/742544 to your computer and use it in GitHub Desktop.
Save kgn/742544 to your computer and use it in GitHub Desktop.
A simple solution for templates
import re
k_regex = re.compile('{{\s*(\w+)\s*}}')
k_template = '''
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
{{content}}
</body>
</html>
'''
def OutputHtml(title, content):
return k_regex.sub(r'%(\1)s', k_template) % locals()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment