이드의 추상화가 마음에 든다면 익스프레스에서 사용하는 데는 아무 문제도 없고, 웹에서 방법
도 쉽게 찾을 수 있습니다.
7.4.
핸들바 기초
핸들바는 다른 인기 있는 템플릿 엔진인 머스태시의 확장입니다. 필자가 핸들바를 권하는 이유
는, 서버에서든 프론트엔드에서든 자바스크립트와 통합하기 쉬우며 문법도 친숙하기 때문입니
다. 필자가 생각하기에 핸들바는 균형을 아주 잘 잡고 있고, 이 책에서도 그런 특징을 주로 설
명할 겁니다. 하지만 이후로 설명할 개념은 다른 템플릿 엔진에도 적용할 수 있으므로, 설령 핸
들바가 마음에 들지 않더라도 다른 템플릿 엔진을 사용할 때 도움이 될 겁니다.
템플릿을 이해하는 데 필요한 핵심 개념은 콘텍스트입니다. 템플릿을 렌더링할 때는 템플릿 엔
진에 콘텍스트 객체를 보내고, 이 객체를 통해 교체가 일어납니다.
예를 들어 콘텍스트 객체가
{
name
: '
Buttercup
' }
이고 템플릿이
<
p
>
Hello
, {{
name
}}!</
p
>
이라면,
{{
name
}}
은
Buttercup
으로 바뀝니다. 템플릿에
HTML
을 보내려면? 예를 들어
앞의 템플릿에 콘텍스트 객체
{
name
: '<
b
>
Buttercup
</
b
>' }
을 보내면 결과는
<
p
>
Hello
,
&
lt
;
b
&
gt
;
Buttercup
&
lt
;
b
&
gt
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.