Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "tarkine", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "tarkine - A powerful and flexible template engine for Node.js applications.", | ||
"main": "src/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/madhanmaaz/tarkine.git" | ||
}, | ||
"author": { | ||
"name": "madhanmaaz", | ||
"url": "http://madhanmaaz.netlify.app/" | ||
}, | ||
"files": [ | ||
@@ -24,7 +32,3 @@ "src/", | ||
], | ||
"author": { | ||
"name": "madhanmaaz", | ||
"url": "http://madhanmaaz.netlify.app/" | ||
}, | ||
"license": "ISC" | ||
} | ||
} |
@@ -93,11 +93,2 @@ <p align="center"> | ||
- Blocks | ||
```js | ||
{{define blockName(param1, param2) }} | ||
// block content | ||
{{/}} | ||
{{ blockName(arg1, arg2) }} | ||
``` | ||
- Code Execution | ||
@@ -104,0 +95,0 @@ ```js |
@@ -5,40 +5,13 @@ const helpers = require("./helpers") | ||
const delimiterPattern = helpers.escapeRegExp(helpers.openDelimiter) + | ||
"\\s*([~#-=/]|define\\s*|for\\s*\\(|if\\s*\\(|else)?\\s*([\\s\\S]*?)\\s*" + | ||
"\\s*([~#-=/]|for\\s*\\(|if\\s*\\(|else)?\\s*([\\s\\S]*?)\\s*" + | ||
helpers.escapeRegExp(helpers.closeDelimiter) | ||
const timeStore = { | ||
ifStart: false, | ||
forStart: false, | ||
defineStart: false, | ||
resetStore() { | ||
this.ifStart = false | ||
this.forStart = false | ||
this.defineStart = false | ||
} | ||
} | ||
function handleDirective(type, content) { | ||
switch (type) { | ||
case '/': {// close brackets | ||
if (timeStore.ifStart || timeStore.forStart) { | ||
timeStore.ifStart = false | ||
timeStore.forStart = false | ||
return "}\n;" | ||
} | ||
case '/': | ||
return "}\n;" | ||
if (timeStore.defineStart) { | ||
timeStore.defineStart = false | ||
return "return function __includeRenderer__() {return __out;};}\n;" | ||
} | ||
} | ||
// define block | ||
case "define": | ||
timeStore.defineStart = true | ||
return `function ${content} {\nlet __out ='';\n` | ||
// loops | ||
case "for (": | ||
case "for(": { | ||
timeStore.forStart = true | ||
const [variables, data] = content.slice(0, -1).split(" in ") | ||
@@ -53,6 +26,4 @@ const [key, value] = variables.split(",") | ||
case "if (": | ||
timeStore.ifStart = true | ||
return `if(${content}{\n` | ||
case "else": | ||
timeStore.ifStart = true | ||
return content.startsWith("if") ? `} else ${content}{\n` : "} else {\n" | ||
@@ -120,3 +91,2 @@ | ||
const errorStore = { line: 0 } | ||
timeStore.resetStore() | ||
@@ -123,0 +93,0 @@ try { |
Sorry, the diff of this file is not supported yet
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
1
21521
395
230