pikpik
unread,Jul 21, 2010, 10:17:01 AM7/21/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to CommonJS
Hi,
Is there any possibility in supporting an embedded code block
structure, if detected per script? This would be similar to the
delimiter functionality found in PHP: "<?php ?>".
In a JavaScript-oriented environment, I would imagine this as:
Begin counting:
<?js for (var i = 0; i < 100; i++) { ?>
I've counted to <?js print(i); ?>...<br />
<?js } ?>
Done counting.
An example preprocessor:
var script = readAsString("script.js");
if (script.match("<?js")) {
//Beginning
script = "print(\"" + script;
//Throughout
script = script.replace("<?js", "\");");
/* This might need to handle line breaks also. */
script = script.replace("?>", "print(\"");
//End
script = script + "\");";
}
eval(script);//...perhaps?
The resulting preprocessed JavaScript (from above) could be:
print("Begin counting:
"); for (var i = 0; i < 100; i++) { print("
I've counted to "); print(i); print("...<br />
"); } print("
Done counting.");
An idea,
pikpik