List in velocity macro, cannot find contains method - eclipse

I put a list strings as validTypes in velocity. When I do :
#if (${validTypes}.contains("aaa"))
// do something
#end
it throws an error. But when I do :
#foreach (${validType} in ${validTypes})
${validType}
#end
it works fine. Do I need to use velocity tools for this? How do I use it in an eclipse plugin?
Are there any work around without using velocity tools?

The problem here is in curly brackets. Just use
#if (${validTypes.contains("aaa")})
or
#if ($validTypes.contains("aaa"))
instead.

For those who concern, this is how to write if not,
#if (!$validTypes.contains("aaa"))

Related

How does babel option ""auxiliaryCommentBefore" or "auxiliaryCommentAfter" work?

I installed Babel("babel-cli": "^6.26.0") and and made a .babelrc like
{
"auxiliaryCommentBefore": "testBefore",
"auxiliaryCommentAfter": "testAfter"
}
and also made a simple test.js like
var a = 5;
and finally run babel test.js.
It secceded but no comment above is attached..
My expectation is something like below.
testBefore
var a = 5;
testAfter
Is there anything required missing??
The honest answer to your question is "they don't" :D
The specific behavior of those two options are extremely under-defined and I would love to rip them out of Babel entirely, and I would except that I don't want to needlessly break existing users when they upgrade.
If you need to annotate some input code in a particular way, you should write your own Babel plugin to inject whatever you need instead.

gwt gss lighten() and darken()

i was trying to use lighten() and darken() in GSS (i'm gwt 2.8 version and material-design rc4) like so:
#def MAIN_COLOR #64b5f6;
#def LIGHTER_COLOR lighter(MAIN_COLOR, 0.5);
.lighter {
color: LIGHTER_COLOR;
}
but the result is
.lighter {
color: lighter(#64b5f6,0.5)
}
i cannot find any sample of using those functions anywhere..
https://github.com/google/closure-stylesheets
i was expecting that those work like in SASS
$primary-color: #64b5f6;
$darken: darken($primary-color, 7%);
$lighten: lighten($primary-color, 20%);
thanks.
I can't reproduce your exact behaviour, but I have managed to get a working example and found the following:
The function name is lighten
The lighten function takes an integer number between 0 and 100 as the amount to lighten by. This is documented directly in the code on GitHub.
I've tried modifying your example as follows and it is working fine:
#def MAIN_COLOR #64b5f6;
#def LIGHTER_COLOR lighten(MAIN_COLOR, 5);
.lighter {
color: LIGHTER_COLOR;
}
This is evaluated, using the latest version of Closure Stylesheets (right now,
v1.4.0) to become the following:
.lighter{color:#7cc1f7}
I expect the number is a percentage lightness increase - that's the method I use in my own color software and is generally what other CSS preprocessor lightening/darkening functions use too - so you might need to play around to get the exact shade you're looking for.
I hope it works for you.

Unity How to use Editor Script to remove StateMachineBehaviour

I have a problem use editor script to remove a statemachinebehaviour,like this:
I use AnimatorState.AddStateMachineBehaviour add the behaviour
The Documentation said use Object.Destroy,I use this api,but it appears:
I want to know how to use Editor Script to implement the function as "remove"
thanks for any idea!!!
In order to remove the state machine behaviour you have to grab the state machine behaviour array, remove the behaviour that you're after, and then reassign the array.
Something along these lines should do it:
using UnityEditor;
using UnityEditor.Animations;
//how you invoke this is up to you
[MenuItem("CONTEXT/StateMachineBehaviour/Remove Test")]
public static void RemoveBehaviour(MenuCommand command)
{
Object selection = Selection.activeObject;
AnimatorState state = selection as AnimatorState;
if(state != null)
{
StateMachineBehaviour behaviour = command.context as StateMachineBehaviour;
StateMachineBehaviour[] theBehaviours = state.behaviours;
ArrayUtility.Remove(ref theBehaviours, behaviour);
Undo.RegisterCompleteObjectUndo(state, "Removed behaviour");
Undo.DestroyObjectImmediate(behaviour);
state.behaviours = theBehaviours;
}
}
This will remove the behaviour using the state machine dropdown menu, with added undo and redo support, an optional bonus.
Depending on how you want to handle the remove, this approach will change but in terms of removing the behaviour, this should be what you're after.
Also, for animator state machines the approach is exactly the same, you just cast the selection object to an AnimatorStateMachine instead.
Hopefully this helps.

Static assets in play java

I have save path in database, when I use it in view
#for(photo <- photos){
<img src="#routes.Assets.versioned("images/photo.getPath()")" class="img-rounded" alt="Cinque Terre" width="304" height="236">
}
photo.getPath() is not working, I try with #photo.getPath() still not working. Any suggest for me. I use play-java version 2.5. Thank a lot.
Personally, I find the Twirl syntax a bit unintuitive. The # marks the start of a scala statement. The length of this statement is determined automatically.
Now looking at the img tag:
<img src="#routes.Assets.versioned("images/photo.getPath()")" class="img-rounded" alt="Cinque Terre" width="304" height="236">
the following piece of code should be identified as a single statement:
routes.Assets.versioned("images/photo.getPath()")
From a scala point of view, the "images/photo.getPath()" is just a String. It will not execute any method on the photo object. I think (I didn't test this) that your issue should be solveable by replacing this part by s"images/${photo.getPath()}". Note that the string interpolation will make sure that the method on the photo object will be called.
This would make your example look like:
#for(photo <- photos) {
<img src="#routes.Assets.versioned(s"images/${photo.getPath()}")" class="img-rounded" alt="Cinque Terre" width="304" height="236">
}

Autohotkey Cannot get "A_Language" to work

I use two different languages.
I would like to switch Capslock and LShift, but only for one of them.
Basically I want to do this:
if (A_Language = "0409")
{
Capslock::LShift
LShift::Capslock
}
// else behave like normal
When I write it like this, the keys are always swapped, no matter the language.
You need to use #if to create context-sensitive hotkeys.
You can read more here: http://ahkscript.org/docs/commands/_If.htm
Also, make sure you're running the latest version of AHK, otherwise it might not work.
#if (A_Language = "0409")
Capslock::LShift
LShift::Capslock
#if