Skip to content
Snippets Groups Projects
Commit 235d1044 authored by echicken's avatar echicken :chicken:
Browse files

Don't shit pants if 'cwd' isn't a thing or a string.

Added xjs_eval(filename, str)
- notionally for evaluating XJS without immediate write
- if str, returns the evaluated script as a string
- if !str, returns the filename that the script was dumped to
- was a fun idea, but doesn't play well with other scripts
- best used with simple and self-contained xjs
parent 751257ee
No related branches found
No related tags found
No related merge requests found
function xjs_compile(filename) {
if(cwd != '') {
if(typeof cwd == 'string' && cwd != '') {
if(filename.search(/^((\/)|([A-Za-z]:[\/\\]))/)==-1)
filename=cwd+filename;
}
......@@ -91,3 +91,29 @@ function xjs_compile(filename) {
}
return(ssjs_filename);
}
function xjs_eval(filename, str) {
const ssjs = xjs_compile(filename);
const f = new File(filename + '.html');
if (!f.open('w+', false)) {
log(LOG_ERR, "!ERROR " + f.error + " creating " + f.name);
return '';
}
function write(s) {
f.write(s);
}
function writeln(s) {
f.writeln(s);
}
load(ssjs);
if (str) {
f.rewind();
const ret = f.read();
f.close();
f.remove();
return ret;
} else {
f.close();
return filename + '.html';
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment