본문 바로가기
FrontEnd

Dust.js 기본 문법 정리

by 이도현 2021. 5. 6.

-- 2022.11.18 

 

이제 홈페이지도 접근되지 않는 걸 보니 이제 더 이상 지원되지 않는 듯 하다

 

---------------------------------------------------------------------------------------------------------------------------

 

이번에 투입된 프로젝트에서 너무 생소한 Dust.js 이라는 템플릿 엔진을 사용한다.

링크드인에서 개발한 것으로 보이는데, 사실상 이제는 사용되는 곳이 거의 없는 것 같다.

하지만 현재 프로젝트에서는 사용하고 있어 기본적인 문법을 알아야만 한다. 

사실 대부분의 템플릿 엔진과 같이 크게 표현 방식이 크게 다른 것 같진 않다.

 

www.dustjs.com/guides/getting-started/

 

Dust.js | Getting Started

Welcome to Dust! The exercises in this tutorial will help you get familiar with Dust’s core features and syntax. To complete the exercises, edit the “Dust Template” or “Data” so that the “Output” matches the “Expected Output”. Writing Tem

www.dustjs.com

 

- 참조

 

{key} 와 같은 형태로 데이터를 참조한다.

 

- . 참조

 

{key.name} 과 같은 형태로 데이터를 참조한다.

 

- 조건문

 

 - ? : exists

 

{?isSelected} selected{/isSelected}

 

 - ^ : not exists

 

{^isSelected} selected{/isSelected}

 

- {:else} : else

 

<li class="result{?isPrimary} primary{:else} secondary{/isPrimary}">

 

  • {@eq}: strictly equal to
  • {@ne}: not strictly equal to
  • {@gt}: greater than
  • {@lt}: less than
  • {@gte}: greater than or equal to
  • {@lte}: less than or equal to

- 섹션

 아래의 두 표현식은 같은 값을 가리킨다

 

{#friend}{name}{/friend}.

{friend.name}

 

- 반복문

 섹션을 정의하고 그 섹션이 배열인 경우 그냥 사용이 가능하다.

'FrontEnd' 카테고리의 다른 글

WebSocket 채팅 기능 관련 참조 페이지  (0) 2021.06.17
Internet Explorer에서 발생하는 Ajax 문제  (0) 2021.06.10
FrontEnd 참조 자료 모음  (0) 2021.05.10