rocket-translator
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -8,3 +8,2 @@ #!/usr/bin/env node | ||
FF = require("../Lib/file-utils").TranslatorFileFunctions, | ||
{startServer} = require("../Lib/server"), | ||
{join} = require("path"), | ||
@@ -11,0 +10,0 @@ {realpathSync} = require("fs"), |
class JavascriptManagement { | ||
constructor(js){ | ||
this.splitReg = /(\n|\r|\r\n)*(?=watch|state|function|var|let|const)/; | ||
this.splitReg = /(\n|\r\n|\r)*(?=watch|state|function(?!\(|\s*\()|var|let|const)/g; | ||
this._watchers = new Array(); | ||
@@ -5,0 +5,0 @@ this._vars = new Array(); |
@@ -150,3 +150,3 @@ const StateManagement = require("./StateManagement"); | ||
} | ||
html = html.replace(new RegExp(`(\t)*<if cond=('|")${e.cond}('|")>(\n|\r|\r\n)${e.if}(\n|\r|\r\n)(\t)*</if>(\r|\n|\r\n)`, "m"), `{data_${id}}`); | ||
html = html.replace(new RegExp(`(\t)*<if cond=('|")${e.cond}('|")>(\n|\r|\r\n)${e.if}(\n|\r|\r\n)(\t)*</if>(\r|\n|\r\n)`, "m"), `\t{data_${id}}`); | ||
html = html.replace(new RegExp(`(\t)*<else>(\n|\r|\r\n)${e.else}</else>`, "m"), ""); | ||
@@ -169,3 +169,2 @@ | ||
} | ||
console.log(new RegExp(`<for val=('|").*('|")>(\\n|\\r|\\r\\n)${e.content.replace(/\(/g, ".").replace(/\)/g ,".").replace(/\t/g, "\\t")}<\\/for>`)) | ||
html = html.replace(new RegExp(`<for val=(\\'|\\").*(\\'|\\")>(\\n|\\r|\\r\\n)${e.content.replace(/\(/g, ".").replace(/\)/g ,".").replace(/\t/g, "\\t")}<\\/for>`), `{data_${id}}`); | ||
@@ -206,32 +205,32 @@ this.loopsState.push({ | ||
if (i !== 0) { | ||
if(e.match(/\w*='w*'/)){ | ||
if(e.match(/^\w*='\w*'/)){ | ||
let isState = false; | ||
let toCompare = e.match(/='\w*(?=')/)[0]; | ||
this.states.forEach(state=>{ | ||
let toCompare = e.match(/^\w*='\w*/g)[0]; | ||
if (typeof state === "object") { | ||
if (toCompare.match(new RegExp(state.key))) { | ||
isState = true; | ||
} | ||
} else { | ||
if (toCompare.match(new RegExp(state))) { | ||
isState = true; | ||
} | ||
state = typeof state === "object" ? state.key : state; | ||
if (toCompare.match(new RegExp(state))) { | ||
isState = true; | ||
} | ||
}) | ||
valueToReturn = e.replace(/'(?=\w*)/, isState ? "{this.state." : "{").replace(/('|\s\-.*')(?=\s|\/)/, "}"); | ||
} else if (e.match(/\w*='\w*\s\?/)) { | ||
} else if (e.match(/^\w*='\w*\s*\-\s*\w*'/)) { | ||
let isState = false; | ||
let toCompare = e.match(/^\w*='\w*/g)[0]; | ||
this.states.forEach(state=>{ | ||
let toCompare = e.match(/^\w*='\w*/g)[0]; | ||
if (typeof state === "object") { | ||
if (toCompare.match(new RegExp(state.key))) { | ||
isState = true; | ||
} | ||
} else { | ||
if (toCompare.match(new RegExp(state))) { | ||
isState = true; | ||
} | ||
state = typeof state === "object" ? state.key : state; | ||
if (toCompare.match(new RegExp(state))) { | ||
isState = true; | ||
} | ||
}) | ||
valueToReturn = e.replace(/'(?=\w*)/, isState ? "{this.state." : "{").replace(/''/, "'}").replace(/}'/, "}}"); | ||
} else if (e.match(/^\w*='\w*\s*\?\s*(\{|\')/)) { | ||
let isState = false; | ||
let toCompare = e.match(/\w*(?=\s*\?)/)[0]; | ||
this.states.forEach(state=>{ | ||
state = typeof state === "object" ? state.key : state; | ||
if (toCompare.match(new RegExp(state))) { | ||
isState = true; | ||
} | ||
}); | ||
valueToReturn = e.replace(/'(?=\w*)/, isState ? "{this.state." : "{").replace(/''/, "'}").replace(/}'/, "}}"); | ||
} | ||
@@ -284,6 +283,6 @@ } else { | ||
let cond = this.condStates.map(e=>{ | ||
return `var data_${e.id};\n\t\tif(this.state.${e.cond}) {\n\t\t\tdata_${e.id} = ${e.if};\n\t\t} ${e.else ? `else {\n\t\t\tdata_${e.id} = ${e.else}`:""}` | ||
return `var data_${e.id};\n\t\tif(this.state.${e.cond}) {\n\t\t\tdata_${e.id} = ${e.if};\n\t\t} ${e.else ? `else {\n\t\t\tdata_${e.id} = ${e.else}\n\t\t}\n\t\t`:""}` | ||
}) | ||
let loops = this.loopsState.map(e=>{ | ||
return `var data_${e.id} = this.state.${e.state}.map(${e.value}=>{\n\t\t\treturn ${this.setReactFilterHTMLState(e.content)}\n\t\t}` | ||
return `var data_${e.id} = this.state.${e.state}.map(${e.value}=>{\n\t\t\treturn ${this.setReactFilterHTMLState(e.content)}\n\t\t}\n\t\t` | ||
}) | ||
@@ -290,0 +289,0 @@ return `${cond ? cond.join("") : ""}${loops ? loops.join(""):""}${this.prerenderComputed.length > 0 ? this.prerenderComputed.join(""):""}`; |
@@ -211,3 +211,3 @@ /** | ||
if (bindData) { | ||
this.states.push(bindData[0].slice(1).split("=")[1]); //Push Bind Data to States | ||
this.states.push(bindData[0].replace(/'|"/g, "").slice(1).split("=")[1]); //Push Bind Data to States | ||
} | ||
@@ -447,3 +447,3 @@ if(bindDataValue){ | ||
data = data | ||
.replace(new RegExp(`\\t(${replace+stateName}|${stateName})`, "g"), "\t"+replace+stateName) | ||
.replace(new RegExp(`\\t(${replace+stateName}|${stateName})(?!\\(|\\s*\\(|\\.)`, "g"), "\t"+replace+stateName) | ||
.replace(new RegExp(`(\\(|\\(\\s*)(${replace+stateName}|${stateName})`, "g"), "("+replace+stateName) | ||
@@ -450,0 +450,0 @@ .replace(new RegExp(`(\\[|\\[\\s*)(${replace+stateName}|${stateName})`, "g"), "["+replace+stateName) |
{ | ||
"name": "rocket-translator", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Translate your HTML files to React.js and Vue.js", | ||
@@ -23,5 +23,5 @@ "keywords": [ | ||
"scripts": { | ||
"publish-major":"git push origin master && npm version major && npm publish --access public", | ||
"publish-minor":"git push origin master && npm version minor && npm publish --access public", | ||
"publish-patch":"git push origin master && npm version patch && npm publish --access public", | ||
"publish-major": "git push origin master && npm version major && npm publish --access public", | ||
"publish-minor": "git push origin master && npm version minor && npm publish --access public", | ||
"publish-patch": "git push origin master && npm version patch && npm publish --access public", | ||
"vue": "node ./bin/cli.js -v", | ||
@@ -28,0 +28,0 @@ "react": "node ./bin/cli.js -r" |
@@ -323,4 +323,15 @@ # RocketJS | ||
``` | ||
### Bind Attributes <a name="binds"></a> | ||
A **Bind Attribute** is a form to set a state value on a tag attribute. And the syntax is like on Vue. | ||
```html | ||
<span :style="stateName">Hello World</span> | ||
``` | ||
And if you want add a default value you must add a `-` follow of the value. | ||
```html | ||
<button :class="classButton - active"></button> | ||
``` | ||
### Styles <a name="styles"></a> | ||
@@ -327,0 +338,0 @@ |
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
84150
373
1480