def process_else(context, data, out): if not to_bool(context[IF_KEY]): try: if data[2] is None or to_bool(evaluate(data[2],context)): render_list(context, data[1], out) context[IF_KEY] = True except Exception,e: #out.write(e) context[IF_KEY] = True
def process_if(context, data, out): test = True try: if to_bool(evaluate(data[2],context)): render_list(context, data[1], out) else: test = False finally: context[IF_KEY]=test
def process_attribute(context, data, out): result = evaluate(data[1],context) if data[2] is None: print_xml_attribute(result, out) elif result is not None: out.write(" ") out.write(data[2]) out.write("=\"") print_xml_attribute(result, out) out.write('"')
def process_for(context, data, out): items = evaluate(data[2],context) if items == None : context[IF_KEY]=False; return; try: children = data[1] var_name = data[3] length = len(items) preious_status = hasattr(context,FOR_KEY) and context[FOR_KEY] for_status = ForStatus(length) context[FOR_KEY]=for_status for item in items: for_status.index += 1 context[var_name]=item render_list(context, children, out) finally: context[FOR_KEY]=preious_status context[IF_KEY]= length > 0
def process_el(context, data, out, encodeXML): value = evaluate(data[1],context) if encodeXML and value is not None: print_xml_text(value, out) else: out.write(value)
def process_var(context, data): context[data[2]]= evaluate(data[1],context);