fix/263 performance regression (#264)

* Replace deep copies in Component.render
* Add 2nd example component to sampleproject
This commit is contained in:
adriaan 2023-04-13 14:20:43 +02:00 committed by GitHub
parent 2cfc7285e1
commit 6f49339c91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 7 deletions

View file

@ -1 +1,13 @@
<div class="calendar-component">Today's date is <span>{{ date }}</span></div>
<div class="calendar-component">
<div>Today's date is <span>{{ date }}</span></div>
<div>Your to-dos:</div>
<ul>
<li>
{% component_block "todo" %}
{% fill "todo_text" %}
Stop forgetting the milk!
{% endfill %}
{% endcomponent_block %}
</li>
</ul>
</div>

View file

@ -0,0 +1,4 @@
<div class="todo-item">
{% slot "todo_text" %}
{% endslot %}
</div>

View file

@ -0,0 +1,9 @@
from django_components import component
@component.register("todo")
class Calendar(component.Component):
# Note that Django will look for templates inside `[your apps]/components` dir and
# `[project root]/components` dir. To customize which template to use based on context
# you can override def get_template_name() instead of specifying the below variable.
template_name = "todo/todo.html"