Page 1 of 1

Executing Macro via Template Trigger ?

Posted: Wed Aug 22, 2007 1:58 pm
by amix

sometimes I'd like to launch a script, that parses text from the current line, takes this as arguments for a script. The script than inserts text into the editor, replacing certain placeholders with the argument.
I could do this as a macro and give it some hotkey, sure, but I'd prefer the macro to act as an 'intelligent' template of some sorts.

Here is an example:
I want to create the documentation-header for a class. As soon I enter

Code: Select all

a script gets launched, that searches the currently opened text for certain patterns (here it would be '@namespace'), extracts '' and adds it to the '@memberOf' part in the header, constructing a header with a part, that reads '@memberOf'.

A full example may look like this:

Code: Select all

/** "public" method 
* @method
* @memberOf YAHOO.myProject.myModule
* @param {Type[, Type, ... ]} [Parameter |...] Parameter-Description
* @return {Type [, Type, ...]} Returns-Description
* @type Object
This documents a Javascript object. Now there is possibilities, to create such an object, that takes arguments and such, that don't.
If, in the editor I'd invoke this as a template like this:

Code: Select all

cdoc param description, param2 description, param3 description, [param4 description]
.Zeus would find the 'cdoc' string, realize it as template-trigger, execute the associated script with all, that is behind the template-trigger as argument. The macro would automatically realize, that the script-doc header needs a '@param' attribute and would also add the parameter-template as I described it.

Posted: Wed Aug 22, 2007 4:02 pm
by amix
Oops, as I just saw in: it is there in the new version. Sorry.