Skip to content

Commit

Permalink
Add docs for template_html.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamghill committed Jul 25, 2024
1 parent 04be090 commit 60e385f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.61.0

- Add [`template_html`](views.md#template_html) to specify inline template HTML on the component.

## 0.60.0

- Silence warnings about multiple root elements for direct views.
Expand Down
22 changes: 22 additions & 0 deletions docs/source/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,28 @@ class HelloWorldView(UnicornView):
template_name = "unicorn/hello-world.html"
```

### template_html

Template HTML can be defined inline on the component instead of using an external HTML file.

```python
# hello_world.py
from django_unicorn.components import UnicornView

class HelloWorldView(UnicornView):
template_html = """<div>
<div>
Count: {{ count }}
</div>
<button unicorn:click="increment">+</button>
<button unicorn:click="decrement">-</button>
</div>
"""

...
```

## Instance properties

### component_args
Expand Down

0 comments on commit 60e385f

Please sign in to comment.