Friday, August 10, 2007

Quick templates Example: Contact XML

A simple example of using "Quick Templates" with a simple piece of XML.
This is a very quick post to show an example of using "Quick Templates" to aid you
in the creation of a repetitive piece of XML
Imagine you have the following XML.
-------------------------------------------------------------
<Contact fname="Rory" lname="Becker"/>
-------------------------------------------------------------
You would like to have many more of these.
What to do?

- Highlight the XML to duplicate.
- Trigger my plugin. (I suggest attaching the "Create Quick Template" action to the "Alt-Q")
- Enter a few keys to trigger your template (In this case perhaps "con")
- Add some choice (crlf separated) keywords to the "Field list". (I think Rory and Becker would work well here. )
- Optionally: Setup a suitable context for you new template.
- Click Ok

Now whenever you activate the template by typing con and hitting space, you will find that the XML is repeated back
to you but that Coderush has wrapped my name (in this case) using it's nice glowing field markers. and you can
effectively type the following
-------------------------------------------------------------
con Mark Miller<enter>
con Carl Franklin<enter>
con Dustin Campbell<enter>
con Richard Campbell<enter>
-------------------------------------------------------------
...and create the following XML...
-------------------------------------------------------------
<Contact fname="Mark" lname="Miller" />
<Contact fname="Carl" lname="Franklin" />
<Contact fname="Dustin" lname="Campbell" />
<Contact fname="Richard" lname="Campbell" />
-------------------------------------------------------------

I'm sure there are many other uses for this.
Feel free to suggest some.

2 comments:

Anonymous said...

The CodeRush wiki is getting vandalized fairly frequently. You might know more than I about how to fix that.

Rory said...

Thanks for letting me know..
..I did have an RSS feed that was supposed to be monitoring changed pages for me but this seems to be broken.

I have now protected a number of pages from being altered by unregistered users.

However to change this to the default is something I do not know about. I have mailed Brandon in hopes that he might have some ideas about this.

Thanks once again