Socket
Socket
Sign inDemoInstall

zpin-templates

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zpin-templates - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

81

dist/reactTemplates.js

@@ -30,3 +30,4 @@ 'use strict';

//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(" ")');
// const 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);} }.bind(this), []).join(" ")');

@@ -211,17 +212,17 @@ function getTagTemplateString(simpleTagTemplate, shouldCreateElement) {

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 (result.endsWith(",")) {
result = result.substr(0, result.length - 1);
}
result = '{[' + result + '].join(\' \')}';
}
props[propKey] = existing + utils.convertText(node, context, result);
// 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(result.endsWith(",")){
// result=result.substr(0,result.length-1);
// }
// result=`{[${result}].join(' ')}`;
// }
props[propKey] = existing + utils.convertText(node, context, val);
}

@@ -343,6 +344,10 @@ } else if (!_.startsWith(key, 'rt-')) {

function convertHtmlToReact(node, context, resourcePath) {
//解决rt不支持script标签
if (node.type == "script") {
node.type = "tag";
}
//bug id选择器名称转化
if (node.type === 'tag' && node.attribs["id"]) {
node.attribs["id"] = '{this.styles["' + node.attribs["id"].trim() + '"]}';
}
// if(node.type==='tag'&&node.attribs["id"]){
// node.attribs["id"]=`{this.styles["${node.attribs["id"].trim()}"]}`;
// }
if (node.name == "Container" && fs.existsSync(path.join(process.cwd(), "dist/config.json"))) {

@@ -656,22 +661,24 @@ var start = resourcePath.indexOf("src\\pages\\");

//2016.12.05
if (tag.attribs.from == "modules" && fs.existsSync(path.join(process.cwd(), "dist/config.json"))) {
var start = resourcePath.indexOf("src\\pages\\");
var arr = resourcePath.substr(start).split("\\");
var moduleName = tag.attribs.name;
var pageName = arr[2];
var config = fs.readFileSync(path.join(process.cwd(), "dist/config.json"), "utf-8");
if (tag.attribs.from == "modules") {
tag.attribs.from = "../../../compile/modules.js";
if (fs.existsSync(path.join(process.cwd(), "dist/config.json"))) {
var start = resourcePath.indexOf("src\\pages\\");
var arr = resourcePath.substr(start).split("\\");
var moduleName = tag.attribs.name;
var pageName = arr[2];
var config = fs.readFileSync(path.join(process.cwd(), "dist/config.json"), "utf-8");
config = JSON.parse(config);
if (!config.pages) {
config.pages = {};
config = JSON.parse(config);
if (!config.pages) {
config.pages = {};
}
if (!config.pages[pageName]) {
config.pages[pageName] = {};
}
if (!config.pages[pageName].modules) {
config.pages[pageName].modules = [];
}
config.pages[pageName].modules.push(moduleName);
fs.writeFileSync(path.join(process.cwd(), "dist/config.json"), JSON.stringify(config));
}
if (!config.pages[pageName]) {
config.pages[pageName] = {};
}
if (!config.pages[pageName].modules) {
config.pages[pageName].modules = [];
}
config.pages[pageName].modules.push(moduleName);
fs.writeFileSync(path.join(process.cwd(), "dist/config.json"), JSON.stringify(config));
tag.attribs.from = "../../../compile/modules.js";
}

@@ -678,0 +685,0 @@ handleImport(tag, context);

{
"name": "zpin-templates",
"version": "0.0.22",
"version": "0.0.23",
"description": "Light weight templates for react -> write html get valid react code",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -37,4 +37,6 @@ '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(this.styles[key]);} }.bind(this), []).join(" ")');
const classSetTemplate = _.template('_(<%= classSet %>).transform(function(res, value, key){ if(value){ res.push(key);} }.bind(this), []).join(" ")');
function getTagTemplateString(simpleTagTemplate, shouldCreateElement) {

@@ -226,17 +228,17 @@ if (simpleTagTemplate) {

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(result.endsWith(",")){
result=result.substr(0,result.length-1);
}
result=`{[${result}].join(' ')}`;
}
props[propKey] = existing + utils.convertText(node, context,result);
// 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(result.endsWith(",")){
// result=result.substr(0,result.length-1);
// }
// result=`{[${result}].join(' ')}`;
// }
props[propKey] = existing + utils.convertText(node, context,val);
}

@@ -360,6 +362,10 @@ } else if (!_.startsWith(key, 'rt-')) {

function convertHtmlToReact(node, context,resourcePath) {
//解决rt不支持script标签
if(node.type=="script"){
node.type="tag";
}
//bug id选择器名称转化
if(node.type==='tag'&&node.attribs["id"]){
node.attribs["id"]=`{this.styles["${node.attribs["id"].trim()}"]}`;
}
// if(node.type==='tag'&&node.attribs["id"]){
// node.attribs["id"]=`{this.styles["${node.attribs["id"].trim()}"]}`;
// }
if(node.name=="Container"&&fs.existsSync(path.join(process.cwd(),"dist/config.json"))){

@@ -662,22 +668,26 @@ var start=resourcePath.indexOf("src\\pages\\");

//2016.12.05
if(tag.attribs.from=="modules"&&fs.existsSync(path.join(process.cwd(),"dist/config.json"))){
var start=resourcePath.indexOf("src\\pages\\");
var arr=resourcePath.substr(start).split("\\");
var moduleName=tag.attribs.name;
var pageName=arr[2];
var config=fs.readFileSync(path.join(process.cwd(),"dist/config.json"),"utf-8");
if(tag.attribs.from=="modules"){
tag.attribs.from="../../../compile/modules.js";
if(fs.existsSync(path.join(process.cwd(),"dist/config.json"))){
var start=resourcePath.indexOf("src\\pages\\");
var arr=resourcePath.substr(start).split("\\");
var moduleName=tag.attribs.name;
var pageName=arr[2];
var config=fs.readFileSync(path.join(process.cwd(),"dist/config.json"),"utf-8");
config=JSON.parse(config);
if(!config.pages){
config.pages={};
config=JSON.parse(config);
if(!config.pages){
config.pages={};
}
if(!config.pages[pageName]){
config.pages[pageName]={}
}
if(!config.pages[pageName].modules){
config.pages[pageName].modules=[]
}
config.pages[pageName].modules.push(moduleName);
fs.writeFileSync(path.join(process.cwd(),"dist/config.json"), JSON.stringify(config))
}
if(!config.pages[pageName]){
config.pages[pageName]={}
}
if(!config.pages[pageName].modules){
config.pages[pageName].modules=[]
}
config.pages[pageName].modules.push(moduleName);
fs.writeFileSync(path.join(process.cwd(),"dist/config.json"), JSON.stringify(config))
tag.attribs.from="../../../compile/modules.js";
}

@@ -684,0 +694,0 @@ handleImport(tag, context);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc