`Primer::Truncate`에서 이전하기
Primer::Truncate에서 이전하기 (Moving Away From Primer::Truncate)
이 가이드는 이제 deprecated된 Primer::Truncate에서 최신 Primer::Beta::Truncate 컴포넌트로 업그레이드하는 방법을 보여줍니다. 새 Truncate 컴포넌트는 이제 잘린 텍스트를 위한 text 슬롯도 포함합니다.
출처: 문서
본문
이 가이드는 이제 deprecated된 Primer::Truncate에서 최신 Primer::Beta::Truncate 컴포넌트로 업그레이드하는 방법을 보여줍니다.
새 Truncate 컴포넌트는 이제 잘린 텍스트를 위한 text 슬롯을 추가로 포함합니다.
마이그레이션 예시 (Some Migration Examples)
Truncate 컴포넌트의 가장 흔한 사용 사례의 마이그레이션은 이름을 바꾸는 것만으로 충분합니다.
이전에는 이렇게 했을 것입니다:
<%= render(Primer::Truncate.new(tag: :p)) { "Some really, really verbose content" } %>
이제는 이렇게:
<%= render(Primer::Beta::Truncate.new(tag: :p)) { "Some really, really verbose content" } %>
tag 인자는 이제 :div 대신 기본값이 :span이므로, 계속 <div> 태그로 콘텐츠를 감싸려면 명시적으로 설정해야 합니다. 그래서 이렇게 사용하고 있었다면:
<%= render(Primer::Truncate.new) { "Some more very very long text" } %>
이제 동등하게 이렇게 쓸 수 있습니다:
<%= render(Primer::Beta::Truncate.new(tag: :div)) { "Some more very very long text" } %>
인자 (Arguments)
컴포넌트 초기화자의 다음 인자들이 deprecated 버전과 최신 버전의 Truncate 컴포넌트 사이에서 변경되었습니다:
| From Primer::Truncate | To Primer::Beta::Truncate | Notes |
|---|---|---|
| tag | tag | Previously defaulted to :div, now :span. |
| inline | n/a | Removed in Primer::Beta::Truncate. |
| n/a | priority | If true, the text will be given priority (by increasing flex-basis). |
Truncate의 나머지 인자는 해당 컴포넌트의 문서에서 찾을 수 있습니다.
완전한 설명과 예시는 다음을 참고하세요.
Primer::Beta::TruncatecomponentPrimer::Beta::TruncateLookbook examples
← Back to development docs
더 알아보기 (Learn more)
Primer::Beta::Truncate컴포넌트 문서에서 새 text 슬롯을 확인해 보세요.<div>래핑을 유지하려면tag: :div를 명시적으로 설정하세요(기본값이:span으로 바뀌었습니다).priority인자로 텍스트에 flex-basis 우선순위를 부여해 보세요.