Permalink
Browse files

pure V3 DOM only working fine in the folder v3_preview

  • Loading branch information...
1 parent b500db9 commit 073ad4587694ecba7f8bd2704bbe81a360cad5be @pure committed Jun 17, 2011
Showing with 174 additions and 277 deletions.
  1. +0 −53 v3_preview/pure2.html
  2. +23 −27 v3_preview/pure3.html
  3. +151 −197 v3_preview/pure3.js
View
@@ -1,53 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
-
-<html lang="en">
-<head>
- <title>pure3</title>
- <script src="../libs/pure.js"></script>
-</head>
-<body>
- <div style="display:none">
- <div class="template">
- <a href="http://"></a>
- <span></span>
- <input type="button" />
- <ul>
- <li class="animal">
- <span class="name"></span>
- <ol>
- <li class="food"></li>
- </ol>
- </li>
- </ul>
- </div>
- </div>
- <div id="result"></div>
- <script>
- var data = {
- who:'wrrrld',
- id:'345',
- href:'beebole.com',
- site:'hello',
- animals:[
- {name:'cat', food:['mouse', 'meat']},
- {name:'mouse', food:['cheese', 'grains']}
- ]
- },
- directive = {
- 'li.animal':{
- 'animal<-animals':{
- 'li.food':{
- 'food<-animal.food':{
- }
- }
- }
- }
- }, rfn;
- rfn = $p('div.template').compile(directive); //!the compiled function returns a DOM node, not a string anymore
- document.getElementById('result').innerHTML = rfn(data);
-
- </script>
-
-</body>
-</html>
View
@@ -7,22 +7,20 @@
<script src="pure3.js"></script>
</head>
<body>
- <div>
- <div class="template">
- <a href="http://"></a>
- <span></span>
- <input type="button" />
- <ul>
- <li class="animal">
- <span class="name">a</span>
- <ol>
- <li class="food">f</li>
- </ol>
- </li>
- </ul>
- </div>
+ <div class="template">
+ <a href="http://"></a>
+ <span class="zoo"></span>
+ <input type="button" />
+ <ul>
+ <li class="animal">
+ <span class="name">a</span>
+ <ol>
+ <li class="food">f</li>
+ </ol>
+ </li>
+ </ul>
</div>
- <div id="result"></div>
+
<script>
var data = {
who:'wrrrld',
@@ -34,34 +32,32 @@
]
},
directive = {
- /*'a':'site',
+ 'a':'site',
'a@href+':'href',
'a@id':'id',
'span':function(){
return this.who;
},
'span@id':'id',
- 'input@value':'anyText',*/
+ 'input@value':'anyText',
'li.animal':{
'animal<-animals':{
-/* '@id':function(a){
+ '@id':function(a){
return this.name[0];
- },*/
- /*'li.food':{
+ },
+ 'li.food':{
'food<-animal.food':{
'.':'food'
}
- },*/
+ },
'span.name':'animal.name'
}
}
- },
-
- template = $p('div.template')[0].cloneNode(true), //!templates are not copied by default anymore
- rfn = $p(template).compile(directive); //!the compiled function returns a DOM node, not a string anymore
- document.getElementById('result').appendChild( rfn(data) );
+ };
+
+ $p('div.template').noClone().render(data, directive);
</script>
</body>
-</html>
+</html>
Oops, something went wrong.

0 comments on commit 073ad45

Please sign in to comment.