Permalink
Browse files

allow @ in the name of a JSON property, add tutorial 5c

  • Loading branch information...
1 parent d905760 commit bc008838c64fd6ec3de2f46a9d569edb647b387b @pure committed Jun 11, 2010
Showing with 59 additions and 4 deletions.
  1. +2 −2 libs/pure.js
  2. +2 −2 libs/pure_packed.js
  3. +55 −0 tutorial/tuto5c.html
View
@@ -7,7 +7,7 @@
Copyright (c) 2010 Michael Cvilic - BeeBole.com
Thanks to Rog Peppe for the functional JS jump
- revision: 2.46
+ revision: 2.47
*/
var $p, pure = $p = function(){
@@ -188,7 +188,7 @@ $p.core = function(sel, ctxt, plugins){
return sel;
}
//check for a valid js variable name with hyphen(for properties only), $, _ and :
- var m = sel.match(/^[a-zA-Z\$_][\w\$:-]*(\.[\w\$:-]*[^\.])*$/);
+ var m = sel.match(/^[a-zA-Z\$_\@][\w\$:-]*(\.[\w\$:-]*[^\.])*$/);
if(m === null){
var found = false, s = sel, parts = [], pfns = [], i = 0, retStr;
// check if literal
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,55 @@
+<html>
+<head>
+ <title>PURE Unobtrusive Rendering Engine</title>
+ <script src="../libs/jquery.js"></script>
+ <script src="../libs/pure.js"></script>
+</head>
+<body>
+ <table>
+ <thead>
+ <tr>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <script>
+ var cols = ['name', 'food', 'legs', 'button'],
+ data = {animals:[
+ {name:'bird', food:'seed', legs:2},
+ {name:'cat', food:'mouse, bird', legs:4},
+ {name:'dog', food:'bone', legs:4},
+ {name:'mouse', food:'cheese', legs:4}
+ ]
+ },
+ colsDir = {
+ 'th':{
+ 'col<-':{
+ '.':'col'
+ }
+ },
+ 'td':{
+ 'col<-':{
+ '@class':'col'
+ }
+ }
+ },
+ dataDir = {
+ 'tbody tr':{
+ 'animal<-animals':{
+ 'td.name':'animal.name',
+ 'td.food':'animal.food',
+ 'td.legs':'animal.legs',
+ 'td.button':'<button onclick="alert(#{animal.legs})">View</button>'
+ }
+ }
+ };
+ $('table').render(cols, colsDir).render(data, dataDir);
+ </script>
+</body>
+</html>

0 comments on commit bc00883

Please sign in to comment.