COTTON_DIR).templates folder can be located in either an app-level or top-level project root folder.Cotton uses the following naming conventions:
COTTON_SNAKE_CASED_NAMES = False see configuration.<c-my-component /><c-sidebar.menu.link />Cotton components can be used with HTML-like syntax or native Django template tags.
Cotton enables you to use html-like syntax to include your components. This tends to enhance productivity as editors and IDEs often provide autocompletion, auto closing and syntax highlighting of xml-like tags out of the box.
<c-button>
Click me
</c-button>
{% cotton button %}
Click me
{% endcotton %}
If you prefer using native template tags you can use Cotton's template tags.
<c-button title="Click me">
Click here
</c-button>
{% cotton button title="Click me" %}
Click here
{% endcotton %}
| Feature | HTML-like Syntax | Native Template Syntax |
|---|---|---|
| Component | <c-button>...</c-button> |
{% cotton button %}...{% endcotton %} |
| Self-closing Component | <c-button /> |
{% cotton button / %} |
| Variables | <c-vars title /> |
{% cotton:vars title %} |
| Named Slot |
|
|