Browse Source

formatting

master
Dylan Baker 3 years ago
parent
commit
73ff055a9e
1 changed files with 59 additions and 52 deletions
  1. 59
    52
      templates/components.html

+ 59
- 52
templates/components.html View File

@@ -1,56 +1,63 @@
1 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
-  {% if type != "index" %}
17
-    <div class="post__body">
18
-      {{ post.html | safe }}
19
-    </div
20
-  {% endif %}
21
-</div>
22
-{% endmacro %} {% macro form(post=false, action) %}
23
-<form class="form" method="POST" action="{{ action }}" id="post-form">
24
-  <input
25
-    type="hidden"
26
-    name="id"
27
-    value="{% if post %}{{ post.id }}{% endif %}"
28
-  />
29
-  <input
30
-    type="hidden"
31
-    name="date"
32
-    value="{% if post %}{{ post.date }}{% endif %}"
33
-  />
34
-  <input type="hidden" name="html" />
35
-  <div class="form__field">
36
-    <label for="title" class="form__label">Title</label>
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 %}
11
+
12
+        {% if logged_in %}
13
+          <a class="post__link" href="/posts/{{ post.id }}/edit">edit</a>
14
+          <span class="post__link danger" data-delete="{{ post.id }}">delete</span>
15
+        {% endif %}
16
+      </div>
17
+    </h3>
18
+
19
+    {% if type != "index" %}
20
+      <div class="post__body">
21
+        {{ post.html | safe }}
22
+      </div>
23
+    {% endif %}
24
+  </div>
25
+{% endmacro %}
26
+
27
+{% macro form(post=false, action) %}
28
+  <form class="form" method="POST" action="{{ action }}" id="post-form">
37 29
     <input
38
-      class="form__text-field"
39
-      type="text"
40
-      name="title"
41
-      required
42
-      value="{% if post %}{{ post.title }}{% endif %}"
30
+      type="hidden"
31
+      name="id"
32
+      value="{% if post %}{{ post.id }}{% endif %}"
43 33
     />
44
-  </div>
45
-  <div class="form__field">
46
-    <label for="body" class="form__label">Body</label>
47
-    <textarea class="form__textarea" name="body" required>
48
-{% if post %}{{ post.body }}{% endif %}</textarea
49
-    >
50
-  </div>
51
-  <div class="form__field">
52
-    <a class="btn" href="#" data-preview>Preview</a>
53
-    <input class="btn" type="submit" value="Post" />
54
-  </div>
55
-</form>
34
+    <input
35
+      type="hidden"
36
+      name="date"
37
+      value="{% if post %}{{ post.date }}{% endif %}"
38
+    />
39
+    <input type="hidden" name="html" />
40
+    <div class="form__field">
41
+      <label for="title" class="form__label">Title</label>
42
+      <input
43
+        class="form__text-field"
44
+        type="text"
45
+        name="title"
46
+        required
47
+        value="{% if post %}{{ post.title }}{% endif %}"
48
+      />
49
+    </div>
50
+    <div class="form__field">
51
+      <label for="body" class="form__label">Body</label>
52
+      <textarea
53
+        class="form__textarea"
54
+        name="body"
55
+        required
56
+      >{% if post %}{{ post.body }}{% endif %}</textarea>
57
+    </div>
58
+    <div class="form__field">
59
+      <a class="btn" href="#" data-preview>Preview</a>
60
+      <input class="btn" type="submit" value="Post" />
61
+    </div>
62
+  </form>
56 63
 {% endmacro %}

Loading…
Cancel
Save