|
@@ -232,6 +232,9 @@ class Template(Node): |
|
|
else: |
|
|
else: |
|
|
return default |
|
|
return default |
|
|
|
|
|
|
|
|
|
|
|
def __getitem__(self, name): |
|
|
|
|
|
return self.get(name) |
|
|
|
|
|
|
|
|
def add(self, name, value, showkey=None, before=None, |
|
|
def add(self, name, value, showkey=None, before=None, |
|
|
preserve_spacing=True): |
|
|
preserve_spacing=True): |
|
|
"""Add a parameter to the template with a given *name* and *value*. |
|
|
"""Add a parameter to the template with a given *name* and *value*. |
|
@@ -312,6 +315,9 @@ class Template(Node): |
|
|
self.params.append(param) |
|
|
self.params.append(param) |
|
|
return param |
|
|
return param |
|
|
|
|
|
|
|
|
|
|
|
def __setitem__(self, name, value): |
|
|
|
|
|
return self.add(name, value) |
|
|
|
|
|
|
|
|
def remove(self, param, keep_field=False): |
|
|
def remove(self, param, keep_field=False): |
|
|
"""Remove a parameter from the template, identified by *param*. |
|
|
"""Remove a parameter from the template, identified by *param*. |
|
|
|
|
|
|
|
@@ -357,3 +363,6 @@ class Template(Node): |
|
|
raise ValueError(name) |
|
|
raise ValueError(name) |
|
|
for i in reversed(to_remove): |
|
|
for i in reversed(to_remove): |
|
|
self.params.pop(i) |
|
|
self.params.pop(i) |
|
|
|
|
|
|
|
|
|
|
|
def __delitem__(self, param): |
|
|
|
|
|
return self.remove(param) |