fis3-parser-umu-i18n
Advanced tools
Comparing version 0.0.6 to 0.0.7
21
index.js
@@ -56,2 +56,19 @@ /** | ||
var preParser = function (content) { | ||
var __lang = '__lang'; | ||
var __html = '__html'; | ||
var __option = '__option'; | ||
var replaceReg = new RegExp('(' + __lang + '|' + __html + '|' + __option + ')' + '\\((.*?)\\)', 'ig'); | ||
return content.replace(replaceReg, function () { | ||
if (arguments.length) { | ||
var replaceString = arguments[0]; | ||
var mod = arguments[1].slice(2); | ||
var value = arguments[2]; | ||
var preSymbol = '['; | ||
var postSymbol = ']'; | ||
return preSymbol + value + postSymbol; | ||
} | ||
}); | ||
} | ||
ejs.filters.replace = function(lang) { | ||
@@ -78,9 +95,9 @@ var params = Array.prototype.slice.call(arguments, 1); | ||
// 渲染 ejs 数据 | ||
content = preParser(content); | ||
try { | ||
content = ejs.render(content, i18nData); | ||
} catch (e) { | ||
console.log(e); | ||
console.log(e, file.realpath); | ||
} | ||
return content; | ||
}; |
{ | ||
"name": "fis3-parser-umu-i18n", | ||
"version": "0.0.6", | ||
"description": "A i18n parser for fis3", | ||
"version": "0.0.7", | ||
"description": "配合i18n-analyzer 对__lang ,__html, __option做预处理", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
3174
91