Abstract class to add an element to another element.
| 180 | |
| 181 | |
| 182 | class MethodCall(MacroElement): |
| 183 | """Abstract class to add an element to another element.""" |
| 184 | |
| 185 | _template = Template( |
| 186 | """ |
| 187 | {% macro script(this, kwargs) %} |
| 188 | {{ this.target }}.{{ this.method }}( |
| 189 | {% for arg in this.args %} |
| 190 | {{ arg | tojavascript }}, |
| 191 | {% endfor %} |
| 192 | {{ this.kwargs | tojavascript }} |
| 193 | ); |
| 194 | {% endmacro %} |
| 195 | """ |
| 196 | ) |
| 197 | |
| 198 | def __init__(self, target: MacroElement, method: str, *args, **kwargs): |
| 199 | super().__init__() |
| 200 | self.target = target.get_name() |
| 201 | self.method = camelize(method) |
| 202 | self.args = args |
| 203 | self.kwargs = kwargs |