Adding your own PS code (snippet) to Sitecore PowerShell Snippets Plugin
While I was playing with scripts in Sitecore PowerShell Extensions, I thought how good and handy it would be to have a comment/uncomment line(s) option in the SPE editor window similar to Visual Studio. So, as I started thinking in those lines, I was looking at options and what I landed might not be perfect but a good start for a weekend exercise! So, I created a code snippet that will just add a # to the code window. Might not be perfect but good that I could explore a couple of other things here!
Note that this insert code snippet option could also be used to store on-demand scripts for content editors: Some regular house-keeping scenarios where you write scripts and hand-over the scripts to the editors to execute as they need - These are also probably scenarios wherein previously you would think of launching SPE from launchpad icon! Now, you can configure the script and allow them to select the configured option from this SPE plugin and enjoy more autonomy!
Anyway, first things first, here is what I did as a hack for commenting a single line in the SPE Script Window:
The PowerShell Plugins ribbon has a handy option to Insert Code Snippets:
This option has some useful snippets like these:
So, if you click something like if-else, you get sample code added to the code window:
Next, if you track where these snippets are picked from, you shouldn't have issues finding the same:
Now, since this is a hack, let us limit the scope to comment one-line in the editor window. For that, let us add a new Snippet Definition Folder and name it Comment:
Comments
Post a Comment