Fetching contributors…
Cannot retrieve contributors at this time
66 lines (51 sloc) 1.67 KB

JS include notations

borschik can merge JS files. But there is no standard method for this in Javascript so borschik uses the following syntax borschik:include:path/to/file.js.

This expression must be in:

  • block comment /*borschik:include:file.js*/
  • curly brackets like object {/*borschik:include:file.js*/}
  • square brackets like array [/*borschik:include:file.js*/]
  • string "borschik:include:file.js".

Comment and string have several semantic.

/* borschik:include:path/file.js */

If include is in a comment it will be replaced by the file's content without any transformation. page.js

var prj = {};
/* borschik:include:components/cookie.js */


var prj = {};
/* components/cookie.js begin */
prj.cookie = {
    set: function(){},
    get: function(){}

/* components/cookie.js end */

There are some problems with code validity in case you want to include JSON file like this

var myData = /* borschik:include:file.json */;

For this case borschik has object and array notations.

// object notation
var myData = {/* borschik:include:file.json */};
// array notation
var myData = [/* borschik:include:file.json */];

In these examples block comment and brackets will be replace with file content.

There is no differents beetween {} and [] notations. This options is for better code style only.


If include is in a string it will be replaced with the result of applying JSON.stringify to the file's content. page.js

prj.STATIC_HOST = "borschik:include:components/host.txt";

page.js will be transformed to:

prj.STATIC_HOST = "//";