Skip to content

Snippet parameters

erinata edited this page Oct 26, 2012 · 7 revisions

There are two ways to fill in the hotspots.

For example, if you create a snippet:

Snippet TriggerText: html-sim
Snippet Content:

<title>$[![]!]</title>
<body>
    <h1>$[![]!]</h1>
    <p>$[![]!]</p>
</body>

When you trigger this snippet by typing html-sim and hit [tab]. This snippet will be triggered as usual and the caret will stay in in title tag.

<title></title>
<body>
    <h1>$[![]!]</h1>
    <p>$[![]!]</p>
</body>

However, if you type html-sim(MyTitle) and hit [tab]. The snippet will be triggered and the text "MyTitle" will be filled into the first hotspot in sight.

<title>MyTitle</title>
<body>
    <h1></h1>
    <p>$[![]!]</p>
</body>

In other words, you can "pass parameters" to snippets when you trigger them. You can pass in as many parameters as you like. For example, if you type html-sim(MyTitle,MyHeading) and hit [tab]. The text "MyTitle" and "MyHeading" will be filled into the first 2 hotspots. And the caret will goto the p tag.

<title>MyTitle</title>
<body>
    <h1>MyHeading</h1>
    <p></p>
</body>

This feature allows you to create more generic snippets. For example, instead of creating a snippet for each type of tags in html, you can create a snippet named "tag"

Snippet TriggerText: tag
Snippet Content:

<$[![tagname]!]>$[0[]0]</$[![tagname]!]>

If you type tag(body) and hit [tab], you will see that the snippet is triggered and the text "body is filled in.

<body></body>

And if you type tag(abc) and hit [tab], the text abc will be filled in to the tagname

<abc></abc>

Therefore this snippet "tag" can be used to generate any kinds of tag. Notice that this example also shows that Multiple Identical Hotspots works seamlessly with parameter passing.

Back to Main Page