Skip to content

Commit 2d15e45

Browse files
committed
Move if statement outside of loop
1 parent 1271520 commit 2d15e45

5 files changed

Lines changed: 587 additions & 669 deletions

File tree

cbv/templates/cbv/klass_detail.html

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,39 +95,37 @@ <h2>Descendants</h2>
9595
</div>
9696

9797
<div class="row">
98-
{% for attribute in attributes %}
99-
{% if forloop.first %}
100-
<div class="span12">
101-
<h2>Attributes</h2>
102-
<table class="table table-striped table-bordered table-condensed">
103-
<thead>
104-
<tr>
105-
<th>&nbsp;</th>
106-
<th>Defined in</th>
107-
</tr>
108-
</thead>
109-
<tbody>
110-
{% endif %}
98+
{% if attributes %}
99+
<div class="span12">
100+
<h2>Attributes</h2>
101+
<table class="table table-striped table-bordered table-condensed">
102+
<thead>
111103
<tr>
112-
<td>
113-
<code class="attribute{%if attribute.overridden %} overridden{% endif %}">
114-
{{ attribute.name }} = {{ attribute.value }}
115-
</code>
116-
</td>
117-
<td>
118-
{% if attribute.klass == klass %}
119-
{{ attribute.klass.name }}
120-
{% else %}
121-
<a href="{{ attribute.klass.get_absolute_url }}">{{ attribute.klass.name }}</a>
122-
{% endif %}
123-
</td>
104+
<th>&nbsp;</th>
105+
<th>Defined in</th>
124106
</tr>
125-
{% if forloop.last %}
107+
</thead>
108+
<tbody>
109+
{% for attribute in attributes %}
110+
<tr>
111+
<td>
112+
<code class="attribute{%if attribute.overridden %} overridden{% endif %}">
113+
{{ attribute.name }} = {{ attribute.value }}
114+
</code>
115+
</td>
116+
<td>
117+
{% if attribute.klass == klass %}
118+
{{ attribute.klass.name }}
119+
{% else %}
120+
<a href="{{ attribute.klass.get_absolute_url }}">{{ attribute.klass.name }}</a>
121+
{% endif %}
122+
</td>
123+
</tr>
124+
{% endfor %}
126125
</tbody>
127126
</table>
128-
</div>
129-
{% endif %}
130-
{% endfor %}
127+
</div>
128+
{% endif %}
131129
</div>
132130
<div class="row">
133131
{% for method in methods %}

tests/_page_snapshots/fuzzy-klass-detail-old.html

Lines changed: 140 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -477,170 +477,150 @@ <h2>Descendants</h2>
477477

478478
<div class="row">
479479

480-
481-
<div class="span12">
482-
<h2>Attributes</h2>
483-
<table class="table table-striped table-bordered table-condensed">
484-
<thead>
485-
<tr>
486-
<th>&nbsp;</th>
487-
<th>Defined in</th>
488-
</tr>
489-
</thead>
490-
<tbody>
491-
492-
<tr>
493-
<td>
494-
<code class="attribute">
495-
content_type = None
496-
</code>
497-
</td>
498-
<td>
499-
500-
<a href="/projects/Django/3.2/django.views.generic.base/TemplateResponseMixin/">TemplateResponseMixin</a>
501-
502-
</td>
503-
</tr>
504-
505-
506-
507-
<tr>
508-
<td>
509-
<code class="attribute">
510-
extra_context = None
511-
</code>
512-
</td>
513-
<td>
514-
515-
<a href="/projects/Django/3.2/django.views.generic.base/ContextMixin/">ContextMixin</a>
516-
517-
</td>
518-
</tr>
519-
520-
521-
522-
<tr>
523-
<td>
524-
<code class="attribute">
525-
form_class = None
526-
</code>
527-
</td>
528-
<td>
529-
530-
<a href="/projects/Django/3.2/django.views.generic.edit/FormMixin/">FormMixin</a>
531-
532-
</td>
533-
</tr>
534-
535-
536-
537-
<tr>
538-
<td>
539-
<code class="attribute">
540-
http_method_names = [&#x27;get&#x27;, &#x27;post&#x27;, &#x27;put&#x27;, &#x27;patch&#x27;, &#x27;delete&#x27;, &#x27;head&#x27;, &#x27;options&#x27;, &#x27;trace&#x27;]
541-
</code>
542-
</td>
543-
<td>
544-
545-
<a href="/projects/Django/3.2/django.views.generic.base/View/">View</a>
546-
547-
</td>
548-
</tr>
549-
550-
551-
552-
<tr>
553-
<td>
554-
<code class="attribute">
555-
initial = {}
556-
</code>
557-
</td>
558-
<td>
559-
560-
<a href="/projects/Django/3.2/django.views.generic.edit/FormMixin/">FormMixin</a>
561-
562-
</td>
563-
</tr>
564-
565-
566-
567-
<tr>
568-
<td>
569-
<code class="attribute">
570-
prefix = None
571-
</code>
572-
</td>
573-
<td>
574-
575-
<a href="/projects/Django/3.2/django.views.generic.edit/FormMixin/">FormMixin</a>
576-
577-
</td>
578-
</tr>
579-
580-
581-
582-
<tr>
583-
<td>
584-
<code class="attribute">
585-
response_class = &lt;class &#x27;django.template.response.TemplateResponse&#x27;&gt;
586-
</code>
587-
</td>
588-
<td>
589-
590-
<a href="/projects/Django/3.2/django.views.generic.base/TemplateResponseMixin/">TemplateResponseMixin</a>
591-
592-
</td>
593-
</tr>
594-
595-
596-
597-
<tr>
598-
<td>
599-
<code class="attribute">
600-
success_url = None
601-
</code>
602-
</td>
603-
<td>
604-
605-
<a href="/projects/Django/3.2/django.views.generic.edit/FormMixin/">FormMixin</a>
606-
607-
</td>
608-
</tr>
609-
610-
611-
612-
<tr>
613-
<td>
614-
<code class="attribute">
615-
template_engine = None
616-
</code>
617-
</td>
618-
<td>
619-
620-
<a href="/projects/Django/3.2/django.views.generic.base/TemplateResponseMixin/">TemplateResponseMixin</a>
621-
622-
</td>
623-
</tr>
624-
625-
626-
480+
<div class="span12">
481+
<h2>Attributes</h2>
482+
<table class="table table-striped table-bordered table-condensed">
483+
<thead>
627484
<tr>
628-
<td>
629-
<code class="attribute">
630-
template_name = None
631-
</code>
632-
</td>
633-
<td>
634-
635-
<a href="/projects/Django/3.2/django.views.generic.base/TemplateResponseMixin/">TemplateResponseMixin</a>
636-
637-
</td>
485+
<th>&nbsp;</th>
486+
<th>Defined in</th>
638487
</tr>
639-
488+
</thead>
489+
<tbody>
490+
491+
<tr>
492+
<td>
493+
<code class="attribute">
494+
content_type = None
495+
</code>
496+
</td>
497+
<td>
498+
499+
<a href="/projects/Django/3.2/django.views.generic.base/TemplateResponseMixin/">TemplateResponseMixin</a>
500+
501+
</td>
502+
</tr>
503+
504+
<tr>
505+
<td>
506+
<code class="attribute">
507+
extra_context = None
508+
</code>
509+
</td>
510+
<td>
511+
512+
<a href="/projects/Django/3.2/django.views.generic.base/ContextMixin/">ContextMixin</a>
513+
514+
</td>
515+
</tr>
516+
517+
<tr>
518+
<td>
519+
<code class="attribute">
520+
form_class = None
521+
</code>
522+
</td>
523+
<td>
524+
525+
<a href="/projects/Django/3.2/django.views.generic.edit/FormMixin/">FormMixin</a>
526+
527+
</td>
528+
</tr>
529+
530+
<tr>
531+
<td>
532+
<code class="attribute">
533+
http_method_names = [&#x27;get&#x27;, &#x27;post&#x27;, &#x27;put&#x27;, &#x27;patch&#x27;, &#x27;delete&#x27;, &#x27;head&#x27;, &#x27;options&#x27;, &#x27;trace&#x27;]
534+
</code>
535+
</td>
536+
<td>
537+
538+
<a href="/projects/Django/3.2/django.views.generic.base/View/">View</a>
539+
540+
</td>
541+
</tr>
542+
543+
<tr>
544+
<td>
545+
<code class="attribute">
546+
initial = {}
547+
</code>
548+
</td>
549+
<td>
550+
551+
<a href="/projects/Django/3.2/django.views.generic.edit/FormMixin/">FormMixin</a>
552+
553+
</td>
554+
</tr>
555+
556+
<tr>
557+
<td>
558+
<code class="attribute">
559+
prefix = None
560+
</code>
561+
</td>
562+
<td>
563+
564+
<a href="/projects/Django/3.2/django.views.generic.edit/FormMixin/">FormMixin</a>
565+
566+
</td>
567+
</tr>
568+
569+
<tr>
570+
<td>
571+
<code class="attribute">
572+
response_class = &lt;class &#x27;django.template.response.TemplateResponse&#x27;&gt;
573+
</code>
574+
</td>
575+
<td>
576+
577+
<a href="/projects/Django/3.2/django.views.generic.base/TemplateResponseMixin/">TemplateResponseMixin</a>
578+
579+
</td>
580+
</tr>
581+
582+
<tr>
583+
<td>
584+
<code class="attribute">
585+
success_url = None
586+
</code>
587+
</td>
588+
<td>
589+
590+
<a href="/projects/Django/3.2/django.views.generic.edit/FormMixin/">FormMixin</a>
591+
592+
</td>
593+
</tr>
594+
595+
<tr>
596+
<td>
597+
<code class="attribute">
598+
template_engine = None
599+
</code>
600+
</td>
601+
<td>
602+
603+
<a href="/projects/Django/3.2/django.views.generic.base/TemplateResponseMixin/">TemplateResponseMixin</a>
604+
605+
</td>
606+
</tr>
607+
608+
<tr>
609+
<td>
610+
<code class="attribute">
611+
template_name = None
612+
</code>
613+
</td>
614+
<td>
615+
616+
<a href="/projects/Django/3.2/django.views.generic.base/TemplateResponseMixin/">TemplateResponseMixin</a>
617+
618+
</td>
619+
</tr>
620+
640621
</tbody>
641622
</table>
642-
</div>
643-
623+
</div>
644624

645625
</div>
646626
<div class="row">

0 commit comments

Comments
 (0)