Revision 4148
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/xml_func.py | ||
---|---|---|
159 | 159 |
# Function names must start with _ to avoid collisions with real tags |
160 | 160 |
# Functions take arguments (items, node) |
161 | 161 |
|
162 |
#### Conditionals |
|
163 |
|
|
164 |
def _if(items, node): |
|
165 |
'''Can add `@name` attr to distinguish separate _if statements''' |
|
166 |
items = dict(items) |
|
167 |
then = items.get('then', None) |
|
168 |
cond = items.get('cond', None) |
|
169 |
else_ = items.get('else', None) |
|
170 |
|
|
171 |
cond = cond != None and bool(cast(strings.ustr, cond)) # None == False |
|
172 |
if cond: return then |
|
173 |
else: return else_ |
|
174 |
funcs['_if'] = _if |
|
175 |
|
|
176 | 162 |
#### Transforming values |
177 | 163 |
|
178 | 164 |
def _collapse(items, node): |
Also available in: Unified diff
xml_func.py: Removed no longer needed _if(), which has been translated to a SQL function