-
Notifications
You must be signed in to change notification settings - Fork 9
Syntax
Alberto Martínez edited this page Sep 7, 2016
·
8 revisions
Defines, or redefines, a jscc (compile-time) variable. You can use expressions.
Undefines a jscc variable.
Includes the block that follows if <expression>
is not falsy.
Includes the block that follows, if the previous `#if/#elif" expressions were falsy.
Ends a #if/#elif#else
sequence.
Test the existence, or nonexistence, of a jscc variable, even if its value is undefined
.
Use __
followed by one or more digits or uppercased letters.
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 in jscc are simple JavaScript, but avoid comments.
Example:
//#set __FOO = ('foo' + 'bar').toUpperCase()
//#set __BAR = __FOO === 'FOOBAR'
console.log($__BAR) // print `true`