Code Snippet Templates

Work Smarter and Faster with Code Snippet Templates

Sometimes a snippet isn't reusable enought by itself. In the past you needed to paste the snippet and then go through it line by line, replacing values to customize it meet your needs. No longer. Snip-It Pro now allows you to define placeholders in your snippets and gives you a way to swap out the placeholders with real values before use.


For example, consider a snippet with common HTML head elements:


<head>
    <title>My Custom Page title</title>
    <meta name="description" content="A Short Description of the page" />
    <meta name="keywords" content="Some Keywords for Google" />
</head>


Looks like a really generic, but reusable snippet. Every time you use it, you would need to go in and replace the "My Custom Page title" with the title of the page, the "A Short Description of the page" with a description of the page and the "Some Keywords for Search Engines" with specific keywords.


This leads to a lot of repetitive work if you use this snippet over and over again, pasting the snippet and then navigating through and replacing everything. Snip-It Pro now allows you to add placeholders to your snippet and gives you a way to swap out the placeholders with real values before use. So Instead, you can define your snippet as:


<head>
    <title>[[Title Text]]</title>
    <meta name="description" content="[[Meta Description]]" />
    <meta name="keywords" content="[[Meta Keywords]]" />
</head>


So where you want a placeholder, just surround a bit of text with double square brackets. Here is a screen shot of editing the snippet:


Use the Configure Snippet bar to specify values to use in the placeholders for the snippet template you are using.

click to enlarge


Notice on the bottom of the screen shot, there is now a new "Configure Snippet" bar at the bottom of the docking window. When a snippet is selected that has placeholders, you can expand this section out and enter values to replace those placeholder values. You could then drag drop or copy and paste that snippet and the place holders will automatically be replaced by the values you enter. As you can see in the following screen shot, I entered "string" into the Property Type Field and "Test" into the Property Name field. I then drag dropped the snippet into TextPad.



When you drag and drop your snippet, Snip-It Pro automatically replaces the placeholders with values you entered in the Configure Snippet Area.

click to enlarge


Snip-It Pro also caches the values you entered into these fields so that if you have multiple snippets with the same placeholder field names, it will remember what values you used so you can quickly use multiple templated snippets without stopping to re-enter data over and over again.