170 |
for item in split_multiple(value): |
for item in split_multiple(value): |
171 |
scope, expr = split_spec(item, 'local', 'global') |
scope, expr = split_spec(item, 'local', 'global') |
172 |
|
|
173 |
|
|
174 |
name, expr = expr.split(None, 1) |
name, expr = expr.split(None, 1) |
175 |
data.append((scope=='global', name, context.compile(expr))) |
data.append((scope=='global', name, context.compile(expr))) |
176 |
return data |
return data |
205 |
#def compile_tal_start(element, context): |
#def compile_tal_start(element, context): |
206 |
# return element |
# return element |
207 |
|
|
208 |
#def compile_tal_finish(element, context): |
def compile_tal_finish(element, context): |
209 |
# return element |
# handle configuration <tal:config prop="value" /> |
210 |
|
if getattr(element, 'ns', None) == tal_ns and element.name == 'config': |
211 |
|
if not hasattr(context, 'tal_configuration'): |
212 |
|
context.tal_configuration = {} |
213 |
|
conf = context.tal_configuration |
214 |
|
for property, value in element.attributes[tal_ns].items(): |
215 |
|
value = [sub.strip().replace(';;', ';') for sub in multiple_re.split(value)] |
216 |
|
if len(value) == 1: |
217 |
|
value = value[0] |
218 |
|
elif len(value) > 1 and not value[-1].strip(): |
219 |
|
del value[-1] # It ended in a semicolon |
220 |
|
conf[property] = value |
221 |
|
# remove it from the compiled tree |
222 |
|
return None |
223 |
|
return element |
224 |
|
|
225 |
|
|
226 |
tal_compiler = AttributeCompiler('tal', tal_ns) |
tal_compiler = AttributeCompiler('tal', tal_ns) |
233 |
tal_compiler.add_handler('attributes', compile_attributes) |
tal_compiler.add_handler('attributes', compile_attributes) |
234 |
tal_compiler.add_handler('omit-tag', compile_omit_tag) |
tal_compiler.add_handler('omit-tag', compile_omit_tag) |
235 |
#tal_compiler.preprocess = compile_tal_start |
#tal_compiler.preprocess = compile_tal_start |
236 |
#tal_compiler.postprocess = compile_tal_finish |
tal_compiler.postprocess = compile_tal_finish |
237 |
|
|
238 |
|
|
239 |
__all__ = ('tal_handler', 'tal_compiler') |
__all__ = ('tal_handler', 'tal_compiler') |