[TxMt] Command Help for templates

Allan Odgaard allan at macromates.com
Tue Feb 15 01:37:59 UTC 2005

On Feb 14, 2005, at 19:53, Ketan Anjaria wrote:

> I have a variable "myPackage" in my template. I would like to replace 
> that with the directory of the template.
> [...] Basically the steps are
> How would I do this? I am not very familiar with perl.

In the template command you can add this line among the variables that 
are setup (e.g. make it line 2):

's#.*include/\(.*\)#\1#p'|tr / .` \

It should do what you want, and then in your template use ${TM_PACKAGE} 
where you want the package name (or change the name of the variable).

If your new file doesn't have 'include' as an ancestor directory, the 
variable will be empty.

More information about the textmate mailing list