modulo
숫자를 제수로 나눈 후 남는 나머지 값을 계산하여 반환하는 나머지 연산 필터입니다.
문법
{{ number | modulo: divisor }}예시
{% assign step = 7 %}{{ step | modulo: 3 }}결과
1modulo 필터는 전달된 숫자를 인수로 지정한 수로 나누었을 때 발생하는 정수 나머지(remainder) 값을 구하는 산술 필터입니다. 짝수/홀수 판별이나 특정 주기로 반복되는 패턴을 설계할 때 가장 핵심적으로 쓰이며 그리드나 리스트 표현을 다양화합니다.
키워드 조합 페이지에서는 상품 목록이나 서비스 특징 그리드에서 행의 인덱스에 따라 지그재그 레이아웃이나 교차 배경색을 부여할 때 자주 사용됩니다. 예를 들어 {% assign is_even = forloop.index | modulo: 2 %}{% if is_even == 0 %}bg-alt{% endif %}처럼 교차 스타일 클래스를 적용하여 시각적 단조로움을 없애고 가독성을 극대화할 수 있습니다.
필터
- 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
