zpin-templates
Advanced tools
Comparing version 0.0.17 to 0.0.19
@@ -27,5 +27,5 @@ 'use strict'; | ||
var propsMergeFunction = 'function mergeProps(inline,external) {\n var res = _.assign({},inline,external)\n if (inline.hasOwnProperty(\'style\')) {\n res.style = _.defaults(res.style, inline.style);\n }\n if (inline.hasOwnProperty(\'className\') && external.hasOwnProperty(\'className\')) {\n res.className = external.className + \' \' + inline.className;\n }\n return res;\n}\n'; | ||
//2016.11.22 rt-class别名转换bug | ||
var classSetTemplate = _.template('_(<%= classSet %>).transform(function(res, value, key){ if(value){ res.push(this.styles[key]);} }.bind(this), []).join(" ")'); | ||
var classSetTemplate = _.template('_(<%= classSet %>).transform(function(res, value, key){ if(value){ res.push(key); } }, []).join(" ")'); | ||
function getTagTemplateString(simpleTagTemplate, shouldCreateElement) { | ||
@@ -208,20 +208,19 @@ if (simpleTagTemplate) { | ||
//多class问题 | ||
// val=val.trim(); | ||
// if(val.indexOf("{this.styles.")<0){ | ||
// var arr=val.split(" "); | ||
// var result="{["; | ||
// arr.forEach(function (v,i) { | ||
// if(classExclude.indexOf(v.trim())<0){ | ||
// result+="this.styles['"+v.trim()+"']"; | ||
// }else{ | ||
// result+=v.trim(); | ||
// } | ||
// if(i!=arr.length-1){ | ||
// result+="," | ||
// } | ||
// }) | ||
// result+="].join(' ')}" | ||
// } | ||
val = val.trim(); | ||
if (val.indexOf("{this.styles.") < 0) { | ||
var arr = val.split(" "); | ||
var result = "{["; | ||
arr.forEach(function (v, i) { | ||
result += 'this.styles["' + v.trim() + '"]'; | ||
if (classExclude.indexOf(v.trim()) > 0) { | ||
result += '' + v.trim(); | ||
} | ||
if (i != arr.length - 1) { | ||
result += ","; | ||
} | ||
}); | ||
result += "].join(' ')}"; | ||
} | ||
// console.log(result); | ||
props[propKey] = existing + utils.convertText(node, context, val.trim()); | ||
props[propKey] = existing + utils.convertText(node, context, result); | ||
} | ||
@@ -343,2 +342,6 @@ } else if (!_.startsWith(key, 'rt-')) { | ||
function convertHtmlToReact(node, context) { | ||
//bug id选择器名称转化 | ||
if (node.type === 'tag' && node.attribs["id"]) { | ||
node.attribs["id"] = '{this.styles["' + node.attribs["id"].trim() + '"]}'; | ||
} | ||
@@ -345,0 +348,0 @@ if (node.type === 'tag' || node.type === 'style') { |
{ | ||
"name": "zpin-templates", | ||
"version": "0.0.17", | ||
"version": "0.0.19", | ||
"description": "Light weight templates for react -> write html get valid react code", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -34,5 +34,5 @@ 'use strict'; | ||
`; | ||
//2016.11.22 rt-class别名转换bug | ||
const classSetTemplate = _.template('_(<%= classSet %>).transform(function(res, value, key){ if(value){ res.push(this.styles[key]);} }.bind(this), []).join(" ")'); | ||
const classSetTemplate = _.template('_(<%= classSet %>).transform(function(res, value, key){ if(value){ res.push(key); } }, []).join(" ")'); | ||
function getTagTemplateString(simpleTagTemplate, shouldCreateElement) { | ||
@@ -223,20 +223,19 @@ if (simpleTagTemplate) { | ||
//多class问题 | ||
// val=val.trim(); | ||
// if(val.indexOf("{this.styles.")<0){ | ||
// var arr=val.split(" "); | ||
// var result="{["; | ||
// arr.forEach(function (v,i) { | ||
// if(classExclude.indexOf(v.trim())<0){ | ||
// result+="this.styles['"+v.trim()+"']"; | ||
// }else{ | ||
// result+=v.trim(); | ||
// } | ||
// if(i!=arr.length-1){ | ||
// result+="," | ||
// } | ||
// }) | ||
// result+="].join(' ')}" | ||
// } | ||
val=val.trim(); | ||
if(val.indexOf("{this.styles.")<0){ | ||
var arr=val.split(" "); | ||
var result="{["; | ||
arr.forEach(function (v,i) { | ||
result+=`this.styles["${v.trim()}"]`; | ||
if(classExclude.indexOf(v.trim())>0){ | ||
result+=`${v.trim()}`; | ||
} | ||
if(i!=arr.length-1){ | ||
result+="," | ||
} | ||
}) | ||
result+="].join(' ')}" | ||
} | ||
// console.log(result); | ||
props[propKey] = existing + utils.convertText(node, context,val.trim()); | ||
props[propKey] = existing + utils.convertText(node, context,result); | ||
} | ||
@@ -360,3 +359,9 @@ } else if (!_.startsWith(key, 'rt-')) { | ||
function convertHtmlToReact(node, context) { | ||
//bug id选择器名称转化 | ||
if(node.type==='tag'&&node.attribs["id"]){ | ||
node.attribs["id"]=`{this.styles["${node.attribs["id"].trim()}"]}`; | ||
} | ||
if (node.type === 'tag' || node.type === 'style') { | ||
@@ -363,0 +368,0 @@ context = _.defaults({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
272408
57
3611