|
Speaker: Kevin Lindsey
Learn how to add a new snippet to insert common text.
|
Hi. Kevin here with Aptana again. I'm gonna talk a bit more about the Actions
View, or more specifically, the Snippet mechanism that we added in Beta 3.2.
So let's take a look at a Snippet in action. Let me go over to this HTML
document and then look under the Actions View in the HTML category, and I
think I'll insert a Script Tag for JavaScript. So I double-click that item,
and now we see we have a Script Element in there.
Our Snippets also allow you to prompt the user for additional information.
So the QuickTime movie is an example of that. So I double-click that item.
You see now that it's asking me for the name of the movie. I'm just going to
call it Test.mov. So we created this whole object and embed elements, and
you see here that we have the name that I typed in plus its source. We have
it again.
Now, one of the nice things is we can edit these templates. So let's
say that we want to have a value that goes right here. So I'm just going to
copy this text. I'm going to go back over to the Actions View, right-click,
Edit Action. So we have a special comment up here, which I'll talk a bit
more of later.
But now we see here we want to add, let's say, Value Equals just empty
for now. So I'm going to save this. And we see some activity over in the
Actions View, and what that did was it actually reloaded this particular
action, which means that now if I go back into this HTML document
and run Insert QuickTime called Test2, we now see that we have that value.
So what this means is that you're able to edit the existing Snippets that
are provided to you with Aptana. So if they're not exactly the way you want it,
you do have more control over those. But to give you even the most control,
let's go ahead and create a new template or a new Snippet of our own.
So under the template category, we have all these Create Actions. I'm going to
go ahead and create an XML Snippet just to do something a little bit different.
So I'm going to double-click that item. The first thing it does is it asks us for
the name of the Snippet. Now, this is the name that's going to appear in the
Action View, so I'm just gonna call this Insert SPG. Now the template that we're
creating - sorry, the Snippet that we're creating has to live in a file, so it's
asking for the name of that file. I'm just going to go with the default.
So this Snippet was created with another Snippet, which defaults.
It inserts the name and a tool tip.
Now, if you notice over here on the left, we already have an Insert SPG.
That's because as soon as we created this Snippet, the action that created it
enters it into the Actions View and then highlights it for us so that we can find
it easily.
Okay, so now all we need to do is simply add some SPG. For those of you I
know I should be defining the name in the default name space, but this is a
demo. Okay, let's see. And then let's give it a radius of let's say 75. And
we'll give that a - make that blue.
Okay, so I'm going to go ahead and save this text because, again, see some
activity in the Actions View, so that has updated this particular Snippet. I see
it in Actions, so let me create a new - I'll call it an SPG file. So this is
empty right now. I double-click Insert SPG. And there's the text that we just
created. And of course, I can preview that and see a nice blue circle.
Okay, now another kind of a little bit more advanced feature is the idea
that you can prompt, and we saw that with the QuickTime Snippet, so what you do
is you, up here in this top section, we enter a prompt command and then the name
of the variable that you want to use. Let's just say we want to define the color.
Now, we need to provide some text to the user so they know what they're entering
information for, so I'll just say, "Please enter the color." Not particularly
exciting, but we save this. And now we'll go back into this SPG file, select that,
and we'll double-click our Insert SPG. And see, now this time it's asking us for
the color.
So I enter red and we get the same thing. Well, that's because now we need to
actually tell this template where we want to use this value. So I'm going to go
to this fill and use the dollar sign open and close curly braces and put the name
of the variable inside of there. And of course, that can be in this file, in this
Snippet, as many times as you want. So I'm going to save that and then we're going
to try inserting that again. This time I'm going to use red. And now you see that
it actually filled in the value, and if I preview it, it is indeed red.
So that covers a bit about Snippets and the Actions View. Hopefully, this will
be something that will help you quite a bit in your editing, and thanks for
listening. Bye.
[End of Video]
|