##// END OF EJS Templates
templater: drop strtoken argument from compiletemplate()...
Yuya Nishihara -
r25598:55c2cb65 default
parent child Browse files
Show More
@@ -93,23 +93,23 b' def tokenizer(data):'
93 93 pos += 1
94 94 yield ('end', None, pos)
95 95
96 def compiletemplate(tmpl, context, strtoken="string"):
96 def compiletemplate(tmpl, context):
97 97 parsed = []
98 98 pos, stop = 0, len(tmpl)
99 99 p = parser.parser(tokenizer, elements)
100 100 while pos < stop:
101 101 n = tmpl.find('{', pos)
102 102 if n < 0:
103 parsed.append((strtoken, tmpl[pos:]))
103 parsed.append(('string', tmpl[pos:]))
104 104 break
105 105 bs = (n - pos) - len(tmpl[pos:n].rstrip('\\'))
106 if strtoken == 'string' and bs % 2 == 1:
107 # escaped (e.g. '\{', '\\\{', but not '\\{' nor r'\{')
108 parsed.append((strtoken, (tmpl[pos:n - 1] + "{")))
106 if bs % 2 == 1:
107 # escaped (e.g. '\{', '\\\{', but not '\\{')
108 parsed.append(('string', (tmpl[pos:n - 1] + "{")))
109 109 pos = n + 1
110 110 continue
111 111 if n > pos:
112 parsed.append((strtoken, tmpl[pos:n]))
112 parsed.append(('string', tmpl[pos:n]))
113 113
114 114 pd = [tmpl, n + 1, stop]
115 115 parseres, pos = p.parse(pd)
General Comments 0
You need to be logged in to leave comments. Login now