Skip to content

Instantly share code, notes, and snippets.

@jackpopp
Created October 12, 2018 14:05
Show Gist options
  • Save jackpopp/afdaaee3db57c7efd6c4ebd04856a887 to your computer and use it in GitHub Desktop.
Save jackpopp/afdaaee3db57c7efd6c4ebd04856a887 to your computer and use it in GitHub Desktop.
Code block 52.js for - test.md
const block = sourceToAST('{}').body[0];
/**
* If the value was true then set the blocks body to the consequent
* If the value was false and there is an alternate set the blocks body to the alternate
* If there is not alternate remove the entire node
*/
if (result) {
block.body = node.consequent.body;
return block;
}
if (result === false) {
if (node.alternate && node.alternate.body) {
block.body = node.alternate.body;
return block;
}
this.remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment