feat: add /plants page
This commit is contained in:
parent
18499631ea
commit
dce23599ef
4 changed files with 51 additions and 17 deletions
|
|
@ -8,9 +8,13 @@
|
|||
</div>
|
||||
{% endmacro info %}
|
||||
|
||||
{% macro name(plant) %}
|
||||
<a hx-get="/plants/{{ plant.id }}" hx-target="#content" hx-push-url="true">{{ plant.name }} (<em>{{ plant.species }}</em>)</a>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro li(plant) %}
|
||||
<li>
|
||||
<a hx-get="/plants/{{ plant.id }}" hx-target="#content" hx-push-url="true">{{ plant.name }}</a> ({{ plant.species }})
|
||||
{{ self::name(plant=plant) }}
|
||||
</li>
|
||||
{% endmacro li %}
|
||||
|
||||
|
|
@ -26,16 +30,9 @@
|
|||
|
||||
{% macro form(target="#plants > ul") %}
|
||||
<form hx-post="/plants" hx-target="{{ target }}" hx-swap="beforeend">
|
||||
<label for="name">Name:</label>
|
||||
<input type="text" id="name" name="name"></br>
|
||||
<label for="species">Species:</label>
|
||||
<input type="text" id="species" name="species"></br>
|
||||
<label for="description">Description:</label>
|
||||
<textarea id="description" name="description" rows=4></textarea></br>
|
||||
<input type="submit">
|
||||
<input type="text" id="name" name="name" placeholder="My super cool plant"></br>
|
||||
<input type="text" id="species" name="species" placeholder="Philodendron Candens"></br>
|
||||
<textarea id="description" name="description" rows=2 placeholder="An additional description"></textarea></br>
|
||||
<input type="submit" value="Add plant">
|
||||
</form>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro name(plant) %}
|
||||
<a hx-get="/plants/{{ plant.id }}" hx-target="#content" hx-push-url="true">{{ plant.name }} (<em>{{ plant.species }}</em>)</a>
|
||||
{% endmacro %}
|
||||
|
|
|
|||
9
templates/views/plants.html
Normal file
9
templates/views/plants.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{% import "components/plant.html" as comp_plant %}
|
||||
|
||||
<h1>Plants</h1>
|
||||
|
||||
<ul>
|
||||
{% for plant in plants %}
|
||||
{{ comp_plant::li(plant=plant) }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
Loading…
Add table
Add a link
Reference in a new issue