PHP Live Templates

Are there PHP live templates (coming soon)?  I know when they do come any I write will pale in comparison, so just seeing if I can skip that step.

Thanks
-Doug

6 comments
Comment actions Permalink

This task is not yet scheduled.  Please, create an issue in our tracker http://youtrack.jetbrains.net/issues/WI to track this task progress. Also, we'd appreciate attachment of your own templates so we can gather best ideas from all users :)

0
Comment actions Permalink

im wondering how to get the functions to work in the php live templates?

here is a list of functions but putting something like the date() into a live template does not replace it like i was expecting.
http://www.jetbrains.com/idea/webhelp/edit-template-variables-dialog.html

template:

/**
* $date()$
* Custom Modules
* @package apCustomCss
* @copyright 2009 by
* @author Michael Ussher
*
*/
// make sure we are not being called directly
defined('IN_SYSTEM') or exit();

I was expecting the date() to be replaced by todays date.

also hoping that variables can be determined.  like if this live template is called from the apCustomCss directory that this variable will be able to be auto-inserted instead of typed by the user.

0
Comment actions Permalink

Michael,

Based on your code sample I assume you are asking about file templates. To have date printed there try $DATE$

The documentation you reference is for live templates, not file templates. Live templates are code snippets that you can auto-expand to code faster.

Hope it helps,
-Eugene

0
Comment actions Permalink

Hi Eugene,

Yes that does help.  I can see for the starting a file that the file templates are probably better than the live templates.

I have one of those set up for my module includes pages now.  But i still cant see how to get the functions to work in the live templates.

in the help (HELP -> HELP TOPICS -> EDIT TEMPLATE VARIABLES DIALOG )
same as this page: http://www.jetbrains.com/idea/webhelp/edit-template-variables-dialog.html

there are 2 sections: CONTROLS and FUNCTIONS
it was one of those in the 'Functions' section that i was trying to use with the live templates.  What i was doing was this.

1. with a current file open in the directory i wanted to create a new file from the editor hit shift+F5 to clone the current file with a different name.
2. ctrl+a to select everything, then del.
3. have a live template set up for apmod (type apmod+TAB)  and the template completes.

if i had date() in the live template it comes out as date() rather than being replaced.   I also tried $date() and $date()$  but neither worked.  i tried the capitalize('some text') expecting to see SOME TEXT but it came out capitalize('some text').

Its not so much of an issue now that i can see the file templates will do the setup for me.  But i dont understand from following the help page how the functions listed there are supposed to work.

Michael

0
Comment actions Permalink

Michael,

Please try this:

  1. Define a variable, e.g. $DATE$
  2. Click 'Edit Variables'
  3. Use date() as expression for the variable, of whatever other function you need.


See screenshot below.
live_template_vars.png

-Eugene

0
Comment actions Permalink

Thanks Eugene,

That works.  I hadn't even noticed the 'edit variables' button on the 'add live templates page'  the button spanned the width of the box and i thought it was a heading for the options below that. (I know it was refered to in the documentation but it didnt filter through into my head.)

These are really interesting.

I might be mis-understanding what the "Default value" is for but the description from the help says "In this text box, specify the default string to be entered in the  corresponding input field of the expanded template, if the                         expression does not give any result after  calculation." http://www.jetbrains.com/idea/webhelp/edit-template-variables-dialog.html

This is what i put for the default value
screenshot_of_edit_variables.png

then when i used the live template in the php editor this is what i was expecting to see:
screenshot_of_live_template_expecting.png

but what i actually got in the editor was:
screenshot_of_live_template_actual.png

Which makes me wonder what the "Default value" is for.

0

Please sign in to leave a comment.