Changeset 4
- Timestamp:
- Mon May 9 12:51:33 2005
- Files:
-
- trunk/cherrytemplate/cherrytemplate.py (modified) (diff)
- trunk/cherrytemplate/unittest/testTagsBis.html (added)
- trunk/cherrytemplate/unittest/unittest.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/cherrytemplate/cherrytemplate.py
r3 r4 148 148 def _writeTemplate(f, template, tab): 149 149 # New cherrytemplate syntax 150 tagList = ['<% =', '<%', '<--']150 tagList = ['<%--', '<%=', '<%'] 150 150 minI = len(template) 151 151 minTag = "" … … 157 157 minI = i 158 158 minTag = tag 159 159 160 if minTag == '<%': 160 161 j = _findClosingTag(template, '<%', '%>', 0, minI + 1, '') … … 175 176 lastIndent -= minIndent 176 177 177 _writeTemplate(f, template[:minI -1], tab)178 _writeTemplate(f, template[:minI], tab) 177 178 lastLineIndent = '' 178 179 for line in lines: … … 190 191 j = _findClosingTag(template, '<%=', '%>', 0, minI + 1, '') 191 192 evalStr = template[minI+3:j] 192 _writeInTripleQuotes(f, template[:minI -1], tab)193 _writeInTripleQuotes(f, template[:minI], tab) 192 193 f.write(tab+'yield %s\n' % evalStr) 193 194 _writeTemplate(f, template[j+2:], tab) 194 195 return 195 196 197 elif minTag == '<%--': 198 j = _findClosingTag(template, '<%--', '--%>', 0, minI + 1, '') 199 _writeInTripleQuotes(f, template[:minI], tab) 200 _writeTemplate(f, template[j+2:], tab) 201 return 196 202 197 203 # Old cherrytemplate syntax … … 446 452 _writeTemplate(f, template, ' ') 447 453 template = f.getvalue() 448 print "*** template:", template 449 print "*** END TEMPLATE" 454 # print "*** template:", template 455 # print "*** END TEMPLATE" 450 456 451 457 g = glob.copy() # make a copy because we don't want to avoid changing original global scope. -
trunk/cherrytemplate/unittest/unittest.py
r2 r4 36 36 name = "world" 37 37 res = cherrytemplate.renderTemplate(file = 'testTags.html') 38 checkRes(res, open('testTags.result', 'r').read()) 38 39 40 print "Testing CGTL (2)...", 41 res = cherrytemplate.renderTemplate(file = 'testTagsBis.html') 39 42 checkRes(res, open('testTags.result', 'r').read()) 40 43 … … 43 46 europoundLatin1 = europoundUnicode.encode('latin-1') 44 47 res = cherrytemplate.renderTemplate(europoundLatin1 + """<py-eval="europoundLatin1">""") 48 print "Testing latin-1 template, latin-1 output (1bis)...", 49 checkRes(res, europoundLatin1*2) 50 res = cherrytemplate.renderTemplate(europoundLatin1 + """<%= europoundLatin1%>""") 45 51 checkRes(res, europoundLatin1*2) 46 52 … … 54 60 55 61 print "Testing unicode template, latin-1 output...", 56 res = cherrytemplate.renderTemplate(europoundUnicode + """<py-eval="europoundUnicode">""", outputEncoding = 'latin-1') 62 res = cherrytemplate.renderTemplate(europoundUnicode + u"""<py-eval="europoundUnicode">""", outputEncoding = 'latin-1') 56 62 checkRes(res, europoundLatin1*2) 57 63
