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.4KB

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