M dss.py +19 -16
@@ 13,21 13,6 @@ import sys
from docutils.core import publish_parts
-# TODO: ie http-equiv tag
-# TODO: generator meta tag?
-# TODO: header with home link
-# TODO: footer with mod date info
-default_template = string.Template('''<!DOCTYPE html>
-<html><head>
- $favicon
- $title
- $stylesheet
- $scripts
-</head><body>
- $content
-</body></html>
-''')
-
def _normpath(p):
return path.normcase(path.normpath(path.abspath(p)))
@@ 58,6 43,24 @@ class LiveSiteHandler(SimpleHTTPRequestH
finally:
os.chdir(prev_cwd)
+class Template(string.Template):
+ delimiter = '~'
+
+# TODO: ie http-equiv tag
+# TODO: generator meta tag?
+# TODO: header with home link
+# TODO: footer with mod date info
+default_template = Template('''<!DOCTYPE html>
+<html><head>
+ ~favicon
+ ~title
+ ~stylesheet
+ ~scripts
+</head><body>
+ ~content
+</body></html>
+''')
+
class DeadSimpleSite(object):
def __init__(self, source):
@@ 156,7 159,7 @@ class DeadSimpleSite(object):
ancestor = path.dirname(ancestor)
if path.exists(template_path):
with open(template_path) as template_in:
- template = string.Template(template_in.read())
+ template = Template(template_in.read())
else:
template = default_template
with open(target, 'w') as html_out:
M test-templates/__template__.html +2 -2
@@ 3,7 3,7 @@
<head>
</head>
<body>
- <a href="${root}index.html">Home</a>
- $content
+ <a href="~{root}index.html">Home</a>
+ ~content
</body>
</html>
No newline at end of file
M test-templates/subdir/subsubdir/__template__.html +1 -1
@@ 3,6 3,6 @@
<head>
</head>
<body>
- $content
+ ~content
</body>
</html>
No newline at end of file
M test/custom.html +3 -3
@@ 1,11 1,11 @@
<!DOCTYPE html>
<html>
<head>
- $stylesheet
- $scripts
+ ~stylesheet
+ ~scripts
</head>
<body>
- $content
+ ~content
<p>Some html content</p>
</body>
</html>
No newline at end of file