Basic ideas:
The URL tag is used to generate the full URL character, the part of the front-end dynamic parameter is filled with the Mr. Foo, and the dynamic parameter is replaced with the regular match.
This approach can be applied in a variety of MVC frameworks, wonderful.
No nonsense, on the yards.
var url = "{URL app=xxxxn&act=yyy&id=[0]}"= Url.format ({$id});
//String.Format simultaneous matching [] () {} content modeif(!String.prototype.format) {String.prototype.format=function () { varargs =arguments; varTag = "; return This. Replace (/(\{|\ (|\[) (\d+) (\}|\) |\])/g,function(Match, m0,m1,m2) {tag= m0+m2; if(tag== ' () ' | | tag = = ' {} ' | | tag = = ' [] ')return typeofARGS[M1]! = ' undefined '? ARGS[M1]: (m0+m1+m2); }); };}
The method of the string object is changed in the way of prototype, it can be rewritten appropriately and become the general function parameter.