You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

components.html 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {% macro post(post, type) %}
  2. <div class="post">
  3. <h3 class="post__heading">
  4. <span class="post__title">
  5. {{ post.title }} <span class="post__date">:: {{ post.date }}</span>
  6. </span>
  7. <div class="post__links">
  8. {% if type == "index" %}
  9. <a class="post__link" href="/posts/{{ post.id }}">view</a>
  10. {% endif %} {% if logged_in %}
  11. <a class="post__link" href="/posts/{{ post.id }}/edit">edit</a>
  12. <span class="post__link danger" data-delete="{{ post.id }}">delete</span>
  13. {% endif %}
  14. </div>
  15. </h3>
  16. <div class="post__body">
  17. {{ post.body | safe }}
  18. </div>
  19. </div>
  20. {% endmacro %} {% macro form(post=false, action) %}
  21. <form class="form" method="POST" action="{{ action }}">
  22. <input
  23. type="hidden"
  24. name="id"
  25. value="{% if post %}{{ post.id }}{% endif %}"
  26. />
  27. <input
  28. type="hidden"
  29. name="date"
  30. value="{% if post %}{{ post.date }}{% endif %}"
  31. />
  32. <div class="form__field">
  33. <label for="title" class="form__label">Title</label>
  34. <input
  35. class="form__text-field"
  36. type="text"
  37. name="title"
  38. required
  39. value="{% if post %}{{ post.title }}{% endif %}"
  40. />
  41. </div>
  42. <div class="form__field">
  43. <label for="body" class="form__label">Body</label>
  44. <textarea class="form__textarea" name="body" required>
  45. {% if post %}{{ post.body }}{% endif %}</textarea
  46. >
  47. </div>
  48. <div class="form__field">
  49. <input class="btn" type="submit" value="Post" />
  50. </div>
  51. </form>
  52. {% endmacro %}