Created
January 17, 2013 16:25
Revisions
-
jeffrydegrande created this gist
Jan 17, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ class Router @prefix = "something" @path: (url)-> @prefix + url @pathWithArgs: (url, args)-> @prefix + url + @serialize(args) @serialize = (obj, prefix) -> str = [] for p, v of obj k = if prefix then prefix + "[" + p + "]" else p if typeof v == "object" str.push(serialize(v, k)) else str.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)) str.join("&") # route definitions @people_path: -> @path "/people" @person_path: (id, args)-> @pathWithArgs("/person/#{id}?", args)