Advertisement
kernel

Untitled

Jul 15th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Template.match('*', function () {
  2.   return this;
  3. });
  4.  
  5. Template.match('table', function (vars) {
  6.   return '<table class="' + this.getAttribute('class') + '">' + Template.applyTemplates(this.childNodes) + '</table>';
  7. });
  8.  
  9. Template.match('table th', function (vars) {
  10.   var out = '';
  11.   var that = this;
  12.   vars.title.forEach(function (val) {
  13.     out += '<th id="' + Template.generateId(that) + '"' + (Template.current.position() == Template.current.last() ? ' class="last"' : '') + '>' + val + '</th>';
  14.   });
  15.   return out;
  16. });
  17.  
  18. Template.match('table th:first-child', function (vars) {
  19.   return '<th id="' + Template.generateId(this) + '">' + vars.title[Template.position()] + '</th>';
  20. });
  21.  
  22. Template.match('div[data-widget]', function (vars) {
  23.   // super awesome stuff goes here
  24. });
  25.  
  26. Template.match('.content div[data-widget]', function (vars) {
  27.   // this is more specific than the above example
  28. });
  29.  
  30. // use sizzle for matching
  31. // write something to find out the best matching css Selector and apply the corresponding template rule -> http://specificity.keegan.st/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement