주말인 경우 빨간 글씨로, 평일인 경우 하늘색
한 파일에 js, html 같이 있게 되었다.
각 줄마다 ejs 태그를 씌여준다.
js는 <% %>
html은 <%= %>
결과
ejs 태그
<% 'Scriptlet' tag, for control-flow, no output
control-flow: ELSE-IF, Switch, While statement,,
this allows you to render different HTML depending on what was the value of variable you got passed in to the template
scriptlet: 모든 종류의 자바스크립트를 쓸 수 있는 것이 아니어서 a full script tag가 아니다.
you have to add it around any part of your code that is not HTML
각 라인 별로 각각 scriplet 태그를 씌여줘야한다.
<%= Outputs the value into the template (HTML escaped)
<h1 style="color: red "> <%= kindOfDay %> list </h1>
<%= %> 은 html 태그 h1 안에 들어있다 .
'Node.js > EJS (Embedded JavaScript Templating' 카테고리의 다른 글
To Do List 6 ] Scope | Local | Globe (0) | 2021.11.01 |
---|---|
To Do List 5] 할일 입력하기 | res.redirect() | 아이템 입력시 ul에 자동 추가되게하기 (0) | 2021.10.30 |
To Do List 4] tolocaleDateString( ) (0) | 2021.10.30 |
To Do List 2] EJS 템플릿 시작하기 (0) | 2021.10.27 |
To Do List 1] 기본 세팅, app.get( ) 형태 (0) | 2021.10.25 |
댓글