Closed jakogut closed 4 years ago
I'm not really interested in adding a flag for such a specific feature or to support a specific JS framework.
Here is a snippet to do what you want without support from the library:
import dominate
class tag_hyphenate(type):
def __new__(cls, name, bases, dict):
return type.__new__(cls, name.replace('_', '-'), bases, dict)
class vue_tag(dominate.dom_tag.dom_tag, metaclass=tag_hyphenate): pass
class v_app(vue_tag): pass
class v_content(vue_tag): pass
class v_container(vue_tag): pass
o = v_app(v_content(v_container('hello world')))
print(o.render())
<v-app>
<v-content>
<v-container>hello world</v-container>
</v-content>
</v-app>
In Python, classes cannot be creating with hyphens, and some front end frameworks such as Vue.js require them.
See here: https://vuetifyjs.com/en/getting-started/quick-start
This necessitates specifying a
tagname
attribute for each custom tag containing a hyphen, which is cumbersome and repetitive.Perhaps the
html_tag
element could have a property such ashyphenate_tagname
that would replace underscores with hyphens during rendering? Then the problem could be solved like so: