File Template - File Username Variable

I've created a new file template.

is it possible to use the filename  used for the file in the file template?

for example:

filename:
Lib

template
class Foo_${class} extends Foo{
}

would create 2 imput fields while creating the file (filename & class)
But because this both are the same, it would be better to have only 1 input field.

thx

0

Hi ragga,

Yes, just use ${NAME} instead:

class Foo_${NAME} extends Foo{
}

0

thx

Didn't know that:)
I checked the help, but there were only:

The available pre-defined file template variables are:            
  • ${USER} - login name of the current                user.
  • ${DATE} - the current system date.
  • ${TIME} - the current system time.
  • ${YEAR} - the current year.
  • ${MONTH} - the current month.
  • ${DAY} - the current day of the                month.
  • ${HOUR} - the current hour.
  • ${MINUTE} - the current minute.             

Maybe you should update this^^
0

Andriy is just your fellow PhpStorm user, voluntarily offering his much appreciated help on our forums.

We will update the docs, filed as http://youtrack.jetbrains.net/issue/WI-5379

0

thx, didn't know this.
I thought he's working also for jetbrains, because he's so active here.


thx for the help:)

0

Currently testing out phpstorm and I am very pleased. It is competing against the two other IDEs - not naming any but you can guess.
How ever: In our company we always start the file with // filename.php
I have tried the ${NAME} variable and that does not work in 2.1.1.

I also wonder if it is possible to do a ${CURSOR} which would tell that the cursor shall be placed here when the new file is generated.

Again: Great IDE! And the $$$ is burning in my pocket.

0

Hello Trond,

I have tried the ${NAME} variable and that does not work in 2.1.1.

I checked your request and realised that we don't provide the ${NAME} variable in 'PHP File', 'PHP Class' and 'PHP Inteface'. Because 'NAME' might be ambiguous(for example for 'PHP Class' template) I think that 'FILE_NAME' is more proper name for such variable. I created an issue about that(http://youtrack.jetbrains.net/issue/WI-6965)  - please vote.

I also wonder if it is possible to do a ${CURSOR} which would tell that the cursor shall be placed here when the new file is generated.

Please create a feature request - http://youtrack.jetbrains.net/issues/WI#newissue=yes

Thank you for feedback!

0

Hello Trond,

The issue is fixed in PhpStorm 2.1.2(http://blogs.jetbrains.com/webide/2011/07/phpstorm-webstorm-2-1-2-released/). Use ${FILE_NAME} variable.

Thank you for feedback!

0

Great! I will test it as I believe I have updated the program. Will you also add {CURSOR} so that the cursor will be placed where you have the tag and so you can continue writing the documentation.

0

Trond,

Will you also add {CURSOR} so that the cursor will be placed where you have the tag and so you can continue writing the documentation.

Please create a feature request - http://youtrack.jetbrains.net/issues/WI#newissue=yes

Thank you for feedback!

0

Hello Trond,

Do you use 'FILE_NAME' template variable? Do you have any issues?

Thank you for feedback!
0

Is there also a way to create the Classname dynamic, depending of the Direction?

e.g.
classname: Ragtek_Foo_Bar_Model_Baz is => library\Ragtek\Foo\Bar\Model\Baz
classname: Gallery_ControllerPublic_Index => library\Gallery\ControllerPublic\Index


So if i create a new File Template with a variable for the name, it should complete the name automatic depending on my folder?

0

请先登录再写评论。