37 lines
907 B
Python
37 lines
907 B
Python
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
from .element import element
|
|
|
|
|
|
class generic_element(element):
|
|
|
|
templates = {"element": "\\{name}{options}{attributes}", "options": "[{content}]"}
|
|
|
|
autolabel = False
|
|
|
|
def __init__(self, name, *args, parent=None, **kargs):
|
|
super().__init__(parent, **kargs)
|
|
self.name = name
|
|
if not args:
|
|
self.attributes = "{}"
|
|
else:
|
|
self.attributes = ""
|
|
for arg in args:
|
|
self.attributes += "{{{}}}".format(arg)
|
|
|
|
def content(self):
|
|
return self.fmt().format(
|
|
"element",
|
|
{
|
|
"name": self.name,
|
|
"attributes": self.attributes,
|
|
"options": self.format_options(self.options),
|
|
},
|
|
)
|
|
|
|
|
|
class factory:
|
|
def __getattr__(self, name):
|
|
return lambda *args, **kargs: generic_element(name, *args, **kargs)
|