##// END OF EJS Templates
templater: extract function that parses template string...
Yuya Nishihara -
r25781:82c91850 default
parent child Browse files
Show More
@@ -127,9 +127,9 b' def tokenize(program, start, end):'
127 pos += 1
127 pos += 1
128 yield ('end', None, pos)
128 yield ('end', None, pos)
129
129
130 def compiletemplate(tmpl, context):
130 def _parsetemplate(tmpl, start, stop):
131 parsed = []
131 parsed = []
132 pos, stop = 0, len(tmpl)
132 pos = start
133 p = parser.parser(elements)
133 p = parser.parser(elements)
134 while pos < stop:
134 while pos < stop:
135 n = tmpl.find('{', pos, stop)
135 n = tmpl.find('{', pos, stop)
@@ -148,7 +148,10 b' def compiletemplate(tmpl, context):'
148
148
149 parseres, pos = p.parse(tokenize(tmpl, n + 1, stop))
149 parseres, pos = p.parse(tokenize(tmpl, n + 1, stop))
150 parsed.append(parseres)
150 parsed.append(parseres)
151 return parsed, pos
151
152
153 def compiletemplate(tmpl, context):
154 parsed, pos = _parsetemplate(tmpl, 0, len(tmpl))
152 return [compileexp(e, context, methods) for e in parsed]
155 return [compileexp(e, context, methods) for e in parsed]
153
156
154 def compileexp(exp, context, curmethods):
157 def compileexp(exp, context, curmethods):
General Comments 0
You need to be logged in to leave comments. Login now