预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共21页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

JavascriptJavascript模板/***Template.class.js***/functionTemplate(){this.classname="Template";this.debug=false;this.file=newHashMap();this.root="";this.varkeys=newHashMap();this.varvals=newHashMap();this.unknowns="remove";this.halt_on_error="yes";this.last_error="";this.fso=newActiveXObject("Scripting.FileSystemObject");this.set_root=_set_root;this.set_unknowns=_set_unknowns;this.get_var=_get_var;this.set_file=_set_file;this.set_var=_set_var;this.set_block=_set_block;this.subst=_subst;this.parse=_parse;this.p=_p;this.pparse=_pparse;this.finish=_finish;this.loadfile=_loadfile;this.is_dir=_is_dir;this.file_exists=_file_exists;this.filename=_filename;this.varname=_varname;this.halt=_halt;this.haltmsg=_haltmsg;}/***设置模板文件根目录*@paramroot*/function_set_root(root){if(!this.is_dir(root)){this.halt("set_root:"+root+"isnotadirectory.");}this.root=root;}/***设定对未知模板变量的处理办法*@paramunknowns*/function_set_unknowns(unknowns){this.unknowns=unknowns;}/***设定模板文件*@paramhandle*@paramfilename*/function_set_file(handle,filename){this.file.put(handle,this.filename(filename));}/***设定模板变量*@paramvarname*@paramvalue*/function_set_var(varname,value){if(!this.varkeys.containsKey(varname)){this.varkeys.put(varname,this.varname(varname));}if(!this.varvals.containsKey(varname)){this.varvals.put(varname,value);}else{this.varvals.remove(varname);this.varvals.put(varname,value);}//alert(varname+"=================="+value);}/***设定块变量*@paramparent*@paramhandle*@paramname*/function_set_block(parent,handle,name){if(!this.loadfile(parent)){this.halt("subst:unabletoload"+parent);}if(name==""){name=handle;}varstr=this.get_var(parent);varre=newRegExp("([sS.]*)");//Matcherm=p.matcher(str);//varrs=m.find();//vart=m.group(m.groupCount());//this.set_var(handle,t);vararr=re.exec(str);if(arr!=null)this.set_var(handle,RegExp.$1);str=str.replace(re,"{"+name+"}");this.set_var(parent,str);}/***进行变量替换*@paramhandle*@return*/function_subst(handle){if(!this.loadfile(handle)){this.halt("subst:unabletoload"+handle);}varstr=this.