Skip to content
This repository was archived by the owner on Oct 23, 2018. It is now read-only.

Modules

dangreen edited this page Jan 3, 2015 · 5 revisions

ColaScript supports exits CommonJS modules and have syntax to create them.

With @import command you can import modules:

@import 'sugar' // import into root scope
@import 'fs' as fs
@import dirname from 'path'
@import print as echo, prompt as ask, test from 'mylib'
		
String code = fs.readFileSync(dirname(filePath) + "/main.cola", "utf8");
echo("hello!");

With @export command you can export and re-export components:

Object hash = {};
Array users = [];
		
@export hash as _, users
@export each as forEach from "underscore"
@export "mylib" // re-export all
Clone this wiki locally