Created
January 14, 2022 16:00
-
-
Save cballenar/c9c3c89f358ed52191b8d139e5ae2aa0 to your computer and use it in GitHub Desktop.
Visual Code Snippet for Drupal's Immediately Invoked Function Expression (IFFE). Add to your JS snippets configuration in VS and call it with `drif`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Drupal IFFE": { | |
"prefix": "drif", | |
"body": [ | |
"/**", | |
"* @name ${1:ScriptName}", | |
"* @description ${2:Script description.}", | |
"* @param {string} input", | |
"* @returns {string} output", | |
"*/", | |
"(function ($, window, Drupal) {", | |
" Drupal.behaviors.blockSettingsSummary = {", | |
" attach: function attach() {", | |
" ${3}", | |
" }", | |
" };", | |
"})(jQuery, window, Drupal);" | |
], | |
"description": "Drupal's recommended Immediate Invoked Function Expression. Source: https://drupalize.me/tutorial/wrap-your-custom-javascript-closure?p=2512." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment