EJS Embedded JavaScript

Programming/JavaScript, Sencha 2017.01.29 19:24 Posted by 파란크리스마스

EJS Embedded JavaScript

출처 : EJS - JavaScript Templates
Getting Started with EJS
JSON Text를 JSON Object로 변환하기 :: Outsider's Dev Story

ejs.zip

JSON Data

{"title":"Cleaning Supplies","supplies":["mop","broom","duster"]}

List Template

<h1><%= title %></h1>
<ul>
<% for(var i=0; i<supplies.length; i++) {%>
	<li><%= supplies[i] %></li>
<% } %>
</ul>

DEMO

<html>

<head>
<!-- EJS -->
<!-- <script type="text/javascript" src="resources/js/ejs_production.js"></script> -->
<script type="text/javascript" src="resources/js/ejs.js"></script>
<script type="text/javascript" src="resources/js/view.js"></script>
</head>
<body>

<p id="ejs_list">Some text here</p>

<script type="text/javascript">
new EJS({url: 'template/list.ejs'}).update('ejs_list', 'template/list.json');
</script>

</body>
</html>

실행결과

저작자 표시
신고


 

티스토리 툴바