Skip to content
Prev Previous commit
Next Next commit
add class as a component param
  • Loading branch information
Archmonger committed Sep 7, 2021
commit 766ca41c7e28199d33b20ab61228bede2206efc6
2 changes: 1 addition & 1 deletion src/django_idom/templates/idom/component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load static %}
<div id="{{ idom_mount_uuid }}"></div>
<div id="{{ idom_mount_uuid }}" class="{{ class }}"></div>
<script type="module" crossorigin="anonymous">
import { mountViewToElement } from "{% static 'js/django-idom-client.js' %}";
const mountPoint = document.getElementById("{{ idom_mount_uuid }}");
Expand Down
4 changes: 3 additions & 1 deletion src/django_idom/templatetags/idom.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
def idom_component(_component_id_, **kwargs):
_register_component(_component_id_)

class_ = kwargs.pop("class","")
json_kwargs = json.dumps(kwargs, separators=(",", ":"))

return {
"class": class_,
"idom_websocket_url": IDOM_WEBSOCKET_URL,
"idom_web_modules_url": IDOM_WEB_MODULES_URL,
"idom_mount_uuid": uuid4().hex,
"idom_component_id": _component_id_,
"idom_component_params": urlencode({"kwargs": json_kwargs}),
"idom_component_params": urlencode({"kwargs": json_kwargs})
}


Expand Down