jsembeds

    1.0.4 • Public • Published

    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.";

    Install

    npm i jsembeds

    DownloadsWeekly Downloads

    1

    Version

    1.0.4

    License

    ISC

    Unpacked Size

    4.17 kB

    Total Files

    4

    Last publish

    Collaborators

    • pc-trollbox