![]() ![]() Or you can combine it into capitalize(camelCase("my awesome class")) to get MyAwesomeClass.Ĭapitalizes all the letters of a string, and inserts an underscore between the parts.įor example, capitalizeAndUnderscore("FooBar"), capitalizeAndUnderscore("foo bar"), and capitalizeAndUnderscore("foo-bar") all return FOO_BAR. The following functions can be used to define live template variables:įor example, camelCase("my-text-file"), camelCase("my text file"), and camelCase("my_text_file") all return myTextFile.Ĭapitalizes the first letter of a string.įor example, capitalize("name") returns Name. For example, if you select EXAMPLE in your code and invoke the "$SELECTION$" template via the assigned abbreviation or by pressing Ctrl+Alt+T and selecting the desired template from the list, PhpStorm will wrap the selection in double quotes as follows: "EXAMPLE".įunctions used in live template variables After the template expands, it wraps the selected text as specified in the template. $SELECTION$ is used in surround templates and denotes the code fragment to be wrapped. $END$ indicates the position of the cursor when the code snippet is complete, and you can no longer press Tab to jump to the next variable. PhpStorm supports the following predefined live template variables that cannot be modified: Specify whether you want to skip the variable when prompting the user for input if the expression evaluated successfully Specify the default value for cases when the expression fails to evaluate In the Edit Template Variables dialog, you can do the following for each variable:ĭefine an expression using predefined functions Specify variables in the template text and click Edit variables. Select a template where you want to configure variables. In the Settings/Preferences dialog ( Ctrl+Alt+S), go to Editor | Live Templates. Predefined functions with possible arguments ![]() ![]() Names of other variables defined in a live template This expression may contain the following constructs: To add a dollar character $ to the template text so that it is not treated as a variable declaration, use the special variable $$.ĭefine each variable using an expression and provide a default value for cases when the expression fails to evaluate. In expressions, use variable names without opening and closing dollar characters $, for example, lowercaseAndDash(ComponentName). To declare variables within templates, use the following format: $VAR$. These may be default values that you can modify or values calculated using functions. When you expand a live template abbreviation, its variables either appear as input fields where you can type values or are replaced with values. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |