본문 바로가기
Developer/Javascript & jQuery

[jquery] 파싱해서 데이터로

by 순수한소년 2017. 1. 30.
728x90
반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>플러그인</title>
</head>
<body>
    <div id="result"></div>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="js/jsrender.js"></script>
    <script>
        $(function() {
            var books = [ {
                isbn : '978-89-5674-578-7',
                image : '06000229',
                title : '예제가 가득한 C 언어 길라잡이',
                price : 20000,
                publish : '정보문화사',
                published : new Date('2012/11/29'),
                authors : [ {
                    name : '김은철',
                    role : '저'
                }, ]
            }, {
                isbn : '978-89-5674-584-8',
                image : '06000228',
                title : '초보자를 위한 C 언어 300제 완전 개정판',
                price : 20000,
                publish : '정보문화사',
                published : new Date('2013/02/14'),
                authors : [ {
                    name : '김은철 ',
                    role : '저'
                }, ]
            }, ];
 
            $('#result').append($('#book').render(books));
        });
    </script>
    <script id="book" type="text/x-jsrender">
<h3>{{:title}}</h3>
<img src="http://www.infopub.co.kr/s_pic/{{>image}}.gif"
  align="right"/>
{{>isbn}}<br />
{{for authors}}
  {{>name}}({{>role}})
{{/for}}<br />
{{>price}}원<br />
{{>publish}}<br />
{{>published}}발행
<hr />
</script>
</body>
</html>
cs


728x90
반응형