for
배열이나 컬렉션의 모든 요소를 순회하며 반복적으로 HTML 블록을 렌더링하는 루프 태그입니다.
문법
{% for item in array %} ... {% endfor %}예시
{% assign tags = "안전,신속,정확" | split: "," %}{% for tag in tags %}[{{ tag }}]{% endfor %}결과
[안전][신속][정확]for 태그는 배열이나 리스트 형태의 데이터 요소를 처음부터 끝까지 하나씩 순회하며 템플릿 블록을 반복 출력하는 루프 제어문입니다. 반복문 내부에서는 forloop 객체를 통해 현재 순번(forloop.index), 첫 번째 여부(forloop.first), 마지막 여부(forloop.last) 등의 유용한 루프 상태 정보에 접근할 수 있습니다.
키워드 조합 페이지에서는 쉼표로 구분되어 입력된 주요 강점이나 제공 서비스 목록 문자열을 split 필터로 나누어 불릿 리스트로 나타낼 때 매우 효과적입니다. 예를 들어 {% assign features = row.features | split: ',' %}{% for f in features %}<li>{{ f | strip }}</li>{% endfor %}처럼 구성하면 단일 셀 데이터로부터 정갈한 HTML 목록 요소를 생성하여 검색 엔진에 구조화된 정보를 전달할 수 있습니다.
필터
- abs
- append
- at_least
- at_most
- capitalize
- ceil
- compact
- concat
- date
- default
- divided_by
- downcase
- escape
- escape_once
- first
- floor
- join
- last
- lstrip
- map
- minus
- modulo
- newline_to_br
- plus
- prepend
- remove
- remove_first
- replace
- replace_first
- reverse
- round
- rstrip
- size
- slice
- sort
- sort_natural
- split
- strip
- strip_html
- strip_newlines
- times
- truncate
- truncatewords
- uniq
- upcase
- url_decode
- url_encode
- where
- raw
- slugify
- number_format
