Comparision with django-cotton #552
Replies: 3 comments 24 replies
-
The ability to define Python objects like lists within the template is really nice! (See Passing Python data types) |
Beta Was this translation helpful? Give feedback.
-
Btw, curiosity got the better of me, and I got a working algo for safely evaluating expressions, so theoretically we could have a similar feature to what django-cotton does python expressions within HTML. E.g. in Cotton, they can pass a static list to a component like so: <c-select name="q1" :options="['yes', 'no', 'maybe']" /> Django-cotton uses The result is that our expressions can contain variables. (For context, unlike plain So, we could have something like this (exaggarated example): {% component "my_comp"
:items="[a for a in [1, 2, *(list_a if 1 > 2 else list_b) ] ]"
:bool_val="not is_active"
:attrs="{**dict_1, **dict_2}"
%}
{% endcomponent %} This would fit nicely with what I talked about in #539. |
Beta Was this translation helpful? Give feedback.
-
For me personally, the syntax of django-cotton itself is a nice feature, which leads me to the following question: @EmilStenstrom Would django-components be open to include an optional cotton-like html tag syntax? We've already started implemented something along those lines in one of our projects to try it out. It's mostly a matter of taste, of course. Upsides of custom html tags are mainly formatting and intellisense regarding css classes by default. I'm using vscode, and I'm also checking out whether (automatically generated!) code snippets and html data providers would help the DX. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/wrabit/django-cotton?tab=readme-ov-file#comparison-with-other-packages
Beta Was this translation helpful? Give feedback.
All reactions