Skip to content
Snippets Groups Projects
Commit 963dde12 authored by deuce's avatar deuce
Browse files

Allow a <?xjs and <? just before the end of a line to enter xjs mode.

Use the infinately more correct toSource() method rather than the horrible
hand-rolled escape_quotes() function.
parent 11428f27
No related branches found
No related tags found
No related merge requests found
......@@ -51,14 +51,22 @@ function xjs_compile(filename) {
}
else {
if(str.search(/<\?(xjs)?\s+/)==-1) {
script += "writeln("+escape_quotes(str)+");";
if(str.substr(-5)=='<?xjs') {
str=str.substr(0, str.length-5);
in_xjs=true;
}
if(str.substr(-2)=='<?') {
str=str.substr(0, str.length-2);
in_xjs=true;
}
script += "writeln("+str.toSource()+");";
str='';
}
else {
str=str.replace(/^(.*?)<\?(xjs)?\s+/,
function (str, p1, p2, offset, s) {
if(p1 != '')
script += "write("+escape_quotes(p1)+");";
script += "write("+p1.toSource()+");";
in_xjs=true;
return '';
}
......@@ -92,10 +100,6 @@ function xjs_compile(filename) {
}
}
return(ssjs_filename);
function escape_quotes(arg) {
return("'"+arg.replace(/'/g,"'+"+'"'+"'"+'"+'+"'")+"'");
}
}
function xjs_load(filename)
......
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