Stay organized with collections
Save and categorize content based on your preferences.
blockly > CodeGenerator > scrub_
CodeGenerator.scrub_() method
Common tasks for generating code from blocks. This is called from blockToCode and is called on every block, not just top level blocks. Subclasses may override this, e.g. to generate code for statements following the block, or to handle comments for the specified block and any connected value blocks.
Signature:
scrub_(_block: Block, code: string, _opt_thisOnly?: boolean): string;
Parameters
Parameter |
Type |
Description |
_block |
Block |
The current block. |
code |
string |
The code created for this block. |
_opt_thisOnly |
boolean |
(Optional) True to generate code for only this statement. |
Returns:
string
Code with comments and subsequent blocks added.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["`scrub_()` is a method within the `CodeGenerator` class used for common code generation tasks from Blockly blocks."],["It's called for every block during code generation, allowing subclasses to customize code output for statements, comments, and connected blocks."],["The method takes the current block, generated code, and an optional flag for generating code for only the current statement as input."],["`scrub_()` returns the modified code, which may include comments and code from subsequent blocks."]]],[]]