2
我想在我的樹枝用於循環使用if語句 - 如果對象(變量)包含一個元素(行) - 然後這個HTML代碼片斷,嫩枝 - 如果對象包含一個元素
這裏就是我正在嘗試,
{% for course in courses %}
<a href="{{ course.courseLink }}"class="courses">
<div class="picture"><img src="{{ asset('/bundles/dproc/assets/images/courses- example.jpg') }}" alt="news-1" title="news-1" /></div>
<div class="title"><h2>{{ course.courseTitle }}</h2></div>
<div class="info">
{{ course.courseContent }}
</div>
</a>
{% endfor %}
此刻courses
只包含一個元素。我的任務是添加一個div
元素,如果它只包含一個元素。
- 我怎麼能在樹枝上做到這一點?
非常感謝您的解決方案 –