[TxMt] Trying to create new file template - not working

Tamara Temple tamouse.lists at gmail.com
Thu Jun 23 22:01:54 UTC 2011


I'm trying to create a new file template, and it's not working for  
some reason. I can run the script in a regular shell and it works  
perfectly, but not within TM.

The script is:

if [[ ! -f "$TM_NEW_FILE" ]]; then
    TM_YEAR=`date +%Y` \
    TM_DATE=`date +%Y-%m-%d` \
    TM_CLASS_NAME=`echo "$TM_NEW_FILE_BASENAME" | perl -pe 'm/ 
^(unitTest|test)/ && s/(unitTest|test)([[:alnum:]_]*)/$2/'` \
    perl -pe 's/\$\{([^}]*)\}/$ENV{$1}/g' \
       < template_in.txt > "$TM_NEW_FILE"
fi

with extension set to "php"

The tempate_in.txt file is:

<?php
/**
  *  ${TM_NEW_FILE_BASENAME}
  * simpletest unit test template: http://www.simpletest.org/
  *
  *  Created by ${TM_FULLNAME} on ${TM_DATE}.
  *  Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights  
reserved.
  *
  * @author ${TM_FULLNAME}
  * @version ${TM_DATE}
  * @package undefined
  */


require_once('simpletest/autorun.php');

include '../class.${TM_CLASS_NAME}.php';

class Test${TM_CLASS_NAME} extends UnitTestCase
{
	private static $testlog = 'testlog.log';
	function setUp()
	{
		error_log(PHP_EOL.'================== 
%<=========================='.'Test${TM_CLASS_NAME} start '.date("Y/m/ 
d.H:i:s").PHP_EOL,3,self::$testlog);
	}
	function test1()
	{
	}
}

?>

When I run it in a normal shell with the command:

rm unitTestDebug.php ; TM_NEW_FILE=$PWD/unitTestDebug.php  
TM_NEW_FILE_BASENAME=unitTestDebug TM_ORGANIZATION_NAME='Miishka'  
TM_FULLNAME='Tamara Temple' sh -vx new.sh

I get a file in the current directory as unitTestDebug.php containing:

<?php
/**
  *  unitTestDebug
  * simpletest unit test template: http://www.simpletest.org/
  *
  *  Created by Tamara Temple on 2011-06-23.
  *  Copyright (c) 2011 Miishka. All rights reserved.
  *
  * @author Tamara Temple
  * @version 2011-06-23
  * @package undefined
  */


require_once('simpletest/autorun.php');

include '../class.Debug.php';

class TestDebug extends UnitTestCase
{
	private static $testlog = 'testlog.log';
	function setUp()
	{
		error_log(PHP_EOL.'================== 
%<=========================='.'TestDebug start '.date("Y/m/ 
d.H:i:s").PHP_EOL,3,self::$testlog);
	}
	function test1()
	{
	}
}

?>

which is exactly what I would expect. If I call up the template in TM  
drawer's new file creation dialog, I get nothing.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture 10.png
Type: image/png
Size: 22310 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20110623/513ce774/attachment-0001.png>
-------------- next part --------------



so I'm stumped.

Any help?



More information about the textmate mailing list