1.0.4 • Published 3 years ago

jsembeds v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

JSEmbeds

NPM

Embed your JS to string, like EJS.

var embeds = require("jsembeds");
console.log(embeds.embed("This is original string, and <embed>\"this is JS\"<closeEmbed> that can cause <embed>throw new Error(\"errors\")<closeEmbed>"))

Customization

evalDriver

Make your eval safe, compiler, etc.

Default: a embed driver that evals the content and replaces any exclusives, like this:

embeds.evalDriver = function(string, exclusive){
	for (var exclusiveName in exclusive){
		while (string.includes(this.exclusivePrefix + exclusiveName)){
			string = string.replace(this.exclusivePrefix + exclusiveName, JSON.stringify(exclusive[exclusiveName]))
		}
	}
	return eval(string);
}
var embeds = require("jsembeds");
embeds.evalDriver = function(args){
	console.log("Attempting to run this!")
	console.log(args);
	console.log("");
	return eval(args);
};

embedOpen and embedClose

Make your embeds with other syntaxes.

Default: and

var embeds = require("jsembeds");
embeds.embedOpen = "<JSembed>";
embeds.embedClose = "</JSembed>";

exclusivePrefix

In this version of program, you can get some exclusives. Like that:

var embeds = require("jsembeds");
embeds.embed("This is an... <embed>exclusiv<closeEmbed>!", {exclusiv: "exclusive"})

You can do a prefix for them.

But this works only for official eval drivers and other rewritten to be compatible.

var embeds = require("jsembeds");
embeds.exclusivePrefix = "Exclusive.";
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago