Skip to content
This repository
Browse code

fixed unicode encoding issue in templates. (closes #17)

  • Loading branch information...
commit 6c1ae1392b13bc2ee76a831a614e80bceea0681d 1 parent 7bb7648
Anand Chitipothu anandology authored

Showing 1 changed file with 6 additions and 5 deletions. Show diff stats Hide diff stats

  1. +6 5 web/template.py
11 web/template.py
@@ -519,12 +519,12 @@ class DefwithNode:
519 519 def __init__(self, defwith, suite):
520 520 if defwith:
521 521 self.defwith = defwith.replace('with', '__template__') + ':'
522   - # offset 3 lines. for __lineoffset__, loop and self.
523   - self.defwith += "\n __lineoffset__ = -3"
  522 + # offset 4 lines. for encoding, __lineoffset__, loop and self.
  523 + self.defwith += "\n __lineoffset__ = -4"
524 524 else:
525 525 self.defwith = 'def __template__():'
526   - # offset 4 lines for __template__, __lineoffset__, loop and self.
527   - self.defwith += "\n __lineoffset__ = -4"
  526 + # offset 4 lines for encoding, __template__, __lineoffset__, loop and self.
  527 + self.defwith += "\n __lineoffset__ = -5"
528 528
529 529 self.defwith += "\n loop = ForLoop()"
530 530 self.defwith += "\n self = TemplateResult(); extend_ = self.extend"
@@ -532,7 +532,8 @@ def __init__(self, defwith, suite):
532 532 self.end = "\n return self"
533 533
534 534 def emit(self, indent):
535   - return self.defwith + self.suite.emit(indent + INDENT) + self.end
  535 + encoding = "# encoding: utf-8\n"
  536 + return encoding + self.defwith + self.suite.emit(indent + INDENT) + self.end
536 537
537 538 def __repr__(self):
538 539 return "<defwith: %s, %s>" % (self.defwith, self.suite)

0 comments on commit 6c1ae13

Branko Vukelic

Comment should probably read "offset 5 lines"

Please sign in to comment.
Something went wrong with that request. Please try again.