fully rewrited to coffeescript and added tag directive support