Skip to content
Alberto Martínez edited this page Sep 7, 2016 · 8 revisions

Syntax

#set

Defines, or redefines, a jscc (compile-time) variable. You can use expressions.

#unset

Undefines a jscc variable.

#if | #elif

Includes the block that follows if <expression> is not falsy.

#else

Includes the block that follows, if the previous `#if/#elif" expressions were falsy.

#endif

Ends a #if/#elif#else sequence.

#ifset | #ifnset

Test the existence, or nonexistence, of a jscc variable, even if its value is undefined.

Variable names

Use __ followed by one or more digits or uppercased letters.

Variable substitution

Prefix the name of the variable to be replaced with $. Inexistent variables are not replaced, nor property identifiers.

Example:

//#set __FOO 'foo'
let bar = '$__FOO'.toUpperCase()  // bar = 'FOO'
let baz = { $__FOO: 'bar' }       // baz = { foo: 'bar' }
console.log('$__FOO')             // print 'foo'
console.log(baz['$__FOO'])        // print 'bar'
console.log(baz.$__FOO)           // ERROR: property-like names are not replaced!

Expressions

Expressions in jscc are simple JavaScript, but avoid comments.

Example:

//#set __FOO = ('foo' + 'bar').toUpperCase()
//#set __BAR = __FOO === 'FOOBAR'
console.log($__BAR)               // print `true`
Clone this wiki locally