str-repeat()
문자 반복 출력 유틸리티 함수
용도
사용법
@debug str-split(".img, .button", ","); // ".img" ".button" 반환로직
@function str-repeat($count: null, $text: null) {
// 전달 인자 유효성 검사
@if type-of($count) != 'number' {
@error 'str-repeat() 믹스인은 첫번째 인자로 숫자 값만 전달 받을 수 있습니다.';
}
@if type-of($text) != 'string' {
@error 'str-repeat() 믹스인은 두번째 인자로 문자 값만 전달 받을 수 있습니다.';
}
// 반복 텍스트 변수
$repeat-text: '';
// 반복 횟수만큼 문자 반복 접합 처리
@for $i from 1 through $count {
$repeat-text: str-insert($repeat-text, '#{$text} ', 1);
}
// 끝 공백 제거
@return str-slice($repeat-text, 1, -2);
}참고
Last updated