代码拉取完成,页面将自动刷新
// nanotemplate
(function() {
var _tregex = /(\$\w+)/g;
String.prototype.template = String.prototype.t = String.prototype.template || function() {
if (arguments[0] instanceof Array)
return arguments[0].map(this.t, this).join("");
else {
var args = typeof arguments[0] === "object" ? arguments[0] : arguments;
return this.replace(_tregex, function(match) { return args[match.substr(1)]; });
}
};
if (typeof Element === "function" || typeof Element === "object")
Element.prototype.template = Element.prototype.t = Element.prototype.template || function() {
this._tcache = this._tcache || this.innerHTML;
this.innerHTML = this._tcache.t.apply(this._tcache, arguments);
};
})();
// main
var objStream = WScript.CreateObject("ADODB.Stream");
var shell = WScript.CreateObject("Wscript.Shell");
var env = shell.Environment("Process");
function Render(filename, params) {
objStream.Charset = "utf-8";
objStream.Open();
objStream.LoadFromFile(filename + '.template');
var input = objStream.ReadText();
objStream.Close();
var output = input.template(params);
objStream.Charset = "utf-8";
objStream.Open();
objStream.WriteText(output);
objStream.SaveToFile(filename, 2);
objStream.Close();
}
if (WScript.Arguments.length == 0) {
WScript.Echo("Usage: " + WScript.ScriptName + " <TargetFile> ENV_VAR ...");
WScript.Quit(1);
}
var filename = WScript.Arguments(0);
var params = {};
var variable;
for (var i = 1; i < WScript.Arguments.length; i++) {
variable = WScript.Arguments(i);
params[variable] = env(variable);
WScript.Echo(variable + "=" + params[variable]);
}
Render(filename, params);
WScript.Echo("Generated " + filename);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。