| | |
| | | |
| | | String namespace = tag.getAttributeValue("namespace"); |
| | | |
| | | return html.replace("this.", namespace + "@"); |
| | | return html.replace("this.", namespace + "_") |
| | | .replaceAll("(id)+( )*+=+( )*+'", "id='" + namespace + "_") |
| | | .replaceAll("(id)+( )*+=+( )*+\"", "id=\"" + namespace + "_"); |
| | | } |
| | | |
| | | private String dealHtmlJs(IProcessableElementTag tag, String js) { |
| | |
| | | |
| | | String namespace = tag.getAttributeValue("namespace"); |
| | | |
| | | return js.replace("this.", "vc.component."+namespace + "@"); |
| | | js = js.replace("this.", "vc.component." + namespace + "_") |
| | | .replaceAll("(\\$)+( )*+(\\()+( )*+\'+#", "\\$('#" + namespace + "_") |
| | | .replaceAll("(\\$)+( )*+(\\()+( )*+\"+#", "\\$(\"#" + namespace + "_"); |
| | | |
| | | //将 监听也做优化 |
| | | js = js.replaceAll("(vc.on)+\\('", "vc.on('" + namespace + "','"); |
| | | js = js.replaceAll("(vc.on)+\\(\"", "vc.on(\"" + namespace + "\",\""); |
| | | return js; |
| | | } |
| | | |
| | | |
| | |
| | | js = js.substring(0, extPos) + tmpProTypes.substring(0, pos).trim() |
| | | + "\nnamespace:'" + namespace.trim() + "',\n" + tmpProTypes.substring(pos, tmpProTypes.length()); |
| | | int position = js.indexOf("{"); |
| | | String propsJs = "\n$namespace='" + namespace.trim() + "';\n"; |
| | | String propsJs = "\nvar $namespace='" + namespace.trim() + "';\n"; |
| | | js = new StringBuffer(js).insert(position + 1, propsJs).toString(); |
| | | return js; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String js = "(function (vc, vm) {vc.extends({a:'123'})})"; |
| | | int extPos = js.indexOf("vc.extends"); |
| | | String tmpProTypes = js.substring(extPos); |
| | | int pos = tmpProTypes.indexOf("{") + 1; |
| | | js = js.substring(0, extPos) + tmpProTypes.substring(0, pos).trim() + "\nnamespace:" + DEFAULT_NAMESPACE + ",\n" + tmpProTypes.substring(pos, tmpProTypes.length()); |
| | | int position = js.indexOf("{"); |
| | | String propsJs = "\n$namespace=" + DEFAULT_NAMESPACE + ";\n"; |
| | | js = new StringBuffer(js).insert(position + 1, propsJs).toString(); |
| | | String js = "123$ ( '#av').val()"; |
| | | js = js.replaceAll("(\\$)+( )*+(\\()+( )*+\'+#", "\\$('#abg_"); |
| | | |
| | | System.out.println(js); |
| | | |
| | | } |
| | | } |