I'm using an existing snippet in Textmate to reduce the repetition of creating controllers and models. The snippet works great, but I'd love to add a comment to the end of each file. For example:
/* End of file filename.php */
/* Location: ./system/application/controllers/filename.php */
The first line is easy:
/* End of file ${TM_FILENAME} */
The second part is almost as easy with the TM_FILEPATH variable:
/* Location: ./${TM_FILEPATH} */
The problem is, I don't want the entire file path returned, just anything AFTER 'system' if it exists, or 'application' if not. For instance, using TM_FILEPATH returns this:
/* Location: ./path/from/root/system/application/controllers/filename.php */
-or-
/* Location: ./path/from/root/application/controllers/filename.php */
...when I want:
/* Location: ./system/application/controllers/filename.php */
-or-
/* Location: ./application/controllers/filename.php */
I assume it is going to be some regex trickery, but I have no idea how. Any suggestions please?
UPDATE: I just found the TextMate variable TM_PROJECT_DIRECTORY which contains the info that I want REMOVED from TM_FILEPATH if that makes things any easier.
So, whereas TM_FILEPATH produces this:
/path/from/root/system/application/controllers/filename.php
TM_PROJECT_DIRECTORY produces this:
/path/from/root