blockly > CodeGenerator > blockToCode
CodeGenerator.blockToCode() method
Generate code for the specified block (and attached blocks). The generator must be initialized before calling this function.
Signature:
blockToCode(block: Block | null, opt_thisOnly?: boolean): string | [string, number];
Parameters
Parameter | Type | Description |
---|---|---|
block | Block | null | The block to generate code for. |
opt_thisOnly | boolean | (Optional) True to generate code for only this statement. |
Returns:
string | [string, number]
For statement blocks, the generated code. For value blocks, an array containing the generated code and an operator order value. Returns '' if block is null.