News for hackers. Stuff that matters.
Re:T.js - A tiny templating framework in ~400 bytes by thezilch on Monday August 13, 2012 @08:34PM (#4378847)
And a few less-featureful templating-frameworks in 140 bytes or less: http://www.140byt.es/keywords/template

Notably, the examples found at https://gist.github.com/964762#file_test.js has the closest parity.

Edit: On second thought, I think the previous gist can reach parity with just a helper function for iterating and escaping:

  function engine(a,b){return function(c,d){return a.replace(/#{([^}]*)}/g,function(a,e){return Function("x","with(x)return "+e).call(c,d||b||{})})}}

  function iterator(o, k, f){
    var i, v = [];
    for(i in o[k]){
      v = v.concat(f(o, k, i));
    }
    return v.join('');
  }

  function print_kv(o, k, i){
    return [" ", i, ":", o[k][i]];
  }

  hello = engine("Hello,#{iterator(this, 'users', print_user)}!")
  // We don't have to pass iterator, on the next line, but it should demonstrate
  // how we context can be overwritten
  hello({users: {a: 1, b: 2, c:3}}, {iterator: iterator, print_user: print_kv})

  // Or don't pass print_user
  print_user = print_kv
  hello({users: {a: 1, b: 2, c:3}})
  // "Hello, a:1 b:2 c:3!"

  // Overload it!
  hello({users: {a: 1, b: 2, c:3}}, {print_user: function(o, k, i){return " "+i}})
  // "Hello, a b c!"
Re:T.js - A tiny templating framework in ~400 bytes by obituary_latte on Monday August 13, 2012 @11:19PM (#4379222)
I had to zoom in like 3 times on my phone to vote this up. I know it may be bad form and all to comment on such, but guhdamn if as newb this doesn't wrinkle my britches.
Re:T.js - A tiny templating framework in ~400 bytes by thezilch on Tuesday August 14, 2012 @12:35AM (#4379423)
Couldn't update my original post, but I was in a rush earlier and couldn't make the proper complete-parity examples: http://news.ycombinator.com/item?id=4379417