Created
December 15, 2010 20:15
-
-
Save kgn/742544 to your computer and use it in GitHub Desktop.
A simple solution for templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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