Closed hanerlend closed 1 month ago
I just render the components inside partials and never return 'just a cotton component'.
For a to-do app, you would likely have a cotton component for the todo card. After that, just render the to-dos using template partials as normal.
Let me know if that makes sense :)
@hanerlend There's nothing specific, I would just mentally place it that a partial can contain any HTML, DTL with or without inserted cotton components.
@hanerlend There's nothing specific, I would just mentally place it that a partial can contain any HTML, DTL with or without inserted cotton components.
That makes sense.
Thinking of it, the component itself does not include anything specific, so I could have a component
"templates/cotton/table-row" containing
{% for row in rows %}
<tr>
{% for cell in row %}
<td>
{{ cell }}
</td>
{% endfor %}
</tr>
{% endfor %}
and I could reference it directly
return render(request, "cotton/table_row.html", context)
Thanks for making it clear! 😊👍
I just render the components inside partials and never return 'just a cotton component'.
@copyfactory thanks! That may be the best way to do it, to make the code consistent, especially within teams.
Hi,
I'm trying out cotton, alongside a couple of other component solutions for Django, like slippers and django-template-partials, together with HTMX.
So far I really like the speed and ease of use that Cotton provides.
Using a simple task-app as an example, this is what I would write in views.py if I were to use django-template-partials :
When using HTMX and cotton, however, I'm a bit unsure - what would be the preferred way to access components when doing a partial reload?
Would you simply address the components directly with "return render(request, "cotton/table_row.html", context)"?