I have a Sublime Text snippet I would like to convert to a PhpStorm's Live Template. Currently I am stuck with the possibility to wrap already defined variables.
e.g.
${2:${1:HOOK}}_mail
A first tab
in sublime text would output the following.
MY_HOOK_mail
A second tab
would then allow me to overwrite the MY_HOOK
MY_OVERWRITE_mail
Would this be possible with live templates?
As reference the sublime text snippet I am trying to convert: https://github.com/iampuma/d7ssnippets/blob/master/hook_mail.sublime-snippet
SOLUTION: - Thanks to @LazyOne.
Live template:
/**
* Implements hook_mail().
*/
function $MODULE_NAME$_mail($key, &$message, $params) {
switch($key) {
case '$MODULE_NAME1$_mail':
$message['subject'] = $SUBJECT$;
$message['body'][] = '$BODY$';
}
}
SOLUTION: - Thanks to @LazyOne.
The trick is just to use the previous variable as default value. E.g:
Live template:
/**
* Implements hook_mail().
*/
function $MODULE_NAME$_mail($key, &$message, $params) {
switch($key) {
case '$MODULE_NAME1$_mail':
$message['subject'] = $SUBJECT$;
$message['body'][] = '$BODY$';
}
}