simple_crud.tpl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. {% macro list(items, links) %}
  2. <a href="{{ url(links.create_link) }}">
  3. {{ 'Add' |trans }}
  4. </a>
  5. <table class="table">
  6. {% for item in items %}
  7. <tr>
  8. <td>
  9. <a href="{{ url(links.read_link, { id: item.id }) }}">
  10. {{ item.name }}
  11. </a>
  12. </td>
  13. <td>
  14. <a class="btn" href="{{ url(links.update_link, { id: item.id }) }}"> {{ 'Edit' |trans }}</a>
  15. <a class="btn" href="{{ url(links.delete_link, { id: item.id }) }}"> {{ 'Delete' |trans }}</a>
  16. </td>
  17. </tr>
  18. {% endfor %}
  19. </table>
  20. {% endmacro %}
  21. {% macro add(form, links) %}
  22. <a href="{{ url(links.list_link) }}">
  23. {{ 'List' |trans }}
  24. </a>
  25. <hr />
  26. <form action="{{ url(links.create_link) }}" method="post" {{ form_enctype(form) }}>
  27. {{ form_widget(form) }}
  28. </form>
  29. {% endmacro %}
  30. {% macro edit(form, links) %}
  31. <a href="{{ url(links.list_link) }}">
  32. {{ 'List' |trans }}
  33. </a>
  34. <form action="{{ url(links.update_link, {id : item.id}) }}" method = "post" {{ form_enctype(form) }}>
  35. {{ form_widget(form) }}
  36. </form>
  37. {% endmacro %}
  38. {% macro read(item, links) %}
  39. <a href="{{ url(links.list_link) }}">
  40. {{ 'List' |trans }}
  41. </a>
  42. <a href="{{ url(links.update_link, {id : item.id}) }}">
  43. {{ 'Edit' |trans }}
  44. </a>
  45. <h2> {{ item.id }}</h2>
  46. <p>{{ item.name }}</p>
  47. {% endmacro %}