Skip to content

Instantly share code, notes, and snippets.

@joemaller
Last active November 11, 2019 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemaller/3e5fe966b32c8ff6a17e7687172fd4cd to your computer and use it in GitHub Desktop.
Save joemaller/3e5fe966b32c8ff6a17e7687172fd4cd to your computer and use it in GitHub Desktop.
Wrap templates in HTML comments which include the filepath
// In VS Code, choose "Preferences: Configure User Snippets" from the Command Palette,
// then choose "New Global Snippets file..." and add this. It's preset to trim file
// paths from "template-parts" or "_includes".
//
// To trigger the snippet, first select the text to be wrapped, choose "Insert Snippet"
// from the Command Palette, then select "Template Start/Stop Comments".
{
"Template Start/Stop Comments": {
"scope": "php,html",
"prefix": "Template Comments Wrap",
"body": [
"<!-- START ${1:${TM_FILEPATH/.*((?:template-parts|_includes)\\/.*)$/$1/}} -->",
"",
"$TM_SELECTED_TEXT",
"",
"<!-- END ${1} -->"
],
"description": "Wrap a template in START/END comments"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment