I want create live template for generate fa-icons
. For example next
<i class="ace-icon fa fa-arrow-right icon-on-right align-top bigger-125"></i>
<i class="ace-icon fa fa-arrow-left icon-on-left bigger-140"></i>
<i class="ace-icon fa fa-times icon-on-right"></i>
<i class="fa fa-bars"></i>
Rules to generate is next:
<i class="fa fa-$ICON_NAME$"></i>
ace-icon
and if it is added setup icon-on-[right|left]
$ICON_NAME$
is fa-arrow-[right|left]
and setted ace-icon
set direction part as it setted in icon-on-[right|left]
align-top
in example$SIZE$
in bigger-$SIZE$
add this class else skip$ICON_NAME$
and $SIZE$
must be predefined.Assumed live template
<i class="$ACE_CLASS$ fa fa-$ICON_NAME$ icon-on-$ACE_DIRECTION$ $OPTIONAL_CLASS$ bigger-$SIZE$"></i>
My questions:
$ICON_NAME$
, $ACE_DIRECTION$
and $SIZE$
?bigger-$SIZE$
if size is empty?$ICON_NAME$
contains $ACE_DIRECTION$
and switch it?icon-on-$ACE_DIRECTION$
and bigger-$SIZE$
only if $ACE_CLASS$
is true?How to setup predefined option list for
$ICON_NAME$
,$ACE_DIRECTION$
and$SIZE$
?
enum(sCompletionString1,sCompletionString2,...)
-- https://www.jetbrains.com/help/phpstorm/2017.1/live-template-variables.html#predefined_functions
How to not render
bigger-$SIZE$
if size is empty?
Not possible -- Live Templates do not have conditions or loops.
I may only suggest to have another enum
with all bigger-XXX
options, including empty one (basically -- instead of bigger-$SIZE$
have $BIGGER-SIZE$
).
2017.2 should have GroovyScript support -- maybe you can then code your own Live Template function or something (see this link for some doc links)...
How check if
$ICON_NAME$
contains$ACE_DIRECTION$
and switch it?
Same as above: not possible -- Live Templates do not have conditions.
How to render
icon-on-$ACE_DIRECTION$
andbigger-$SIZE$
only if$ACE_CLASS$
is true?
Same as above: not possible -- Live Templates do not have conditions.
You may create more than one Live Template that would cover few different scenarios (they would have different abbreviations, of course: e.g. fai
for one case, fai2
for another etc).