Is there a way to colorize a function's static variable?
I have tried to customize editor.tokenColorCustomizations. For that i have used "Inspect Editor Token and Scopes" and them field "modifiers".
I have figured out static local variable has only "local" modifiers just like non-static local variable.
I also have tried to use "storage.modifiers.static" scope, but it highlights a static-keyword, not the variable.
Related
Whenever I am adding this documentation to Postman, it changes my global variable /{{tenantName}} to an object like /:tenantName.
Does anybody have solution for it?
I am wondering if there is a way to remove all the global variables clicking somewhere in Postman. I know how to use environment variables and how to switch among them but I want to get rid of all the global variables at once.
I'm using Solidus/Spree.
Normally when you use variables from the controller, you use instance variables that start with an #.
In my views, I have seen the use of current_spree_user which is not an instance variable, but it does work. I don't see this local variable 'current_spree_user' being assigned somewhere in my view.
Anybody knows how it is possible that current_spree_user is an valid variable within a view?
It's not an controller instance variable, but controller helper method :
https://github.com/spree/spree_auth_devise/blob/master/lib/spree/authentication_helpers.rb
I'd like to pass specific values to various custom tags, like thus:
<cfif someerror>
<cfset mytag.bordercolor = "red">
</cfif>
<cf_input id="mytag">
Is this possible in some way?
According to the documentation, what you have should work EXCEPT that you forgot to enclose the variable name between hashtags #. Try this instead:
<cf_input id="#mytag#">
There are some important things to keep in mind on how the variables get passed to custom tags.
From the documentation - Passing variables to custom tags and UDFs
Passing variables to CFML tags and UDFs
When you pass a variable to a CFML custom tag as an attribute, or to a user-defined function as an argument, the following rules determine whether the custom tag or function receives its own private copy of the variable or only gets a reference to the calling page's variable:
Simple variables and arrays are passed as copies of the data. If your argument is an expression that contains multiple simple variables, the result of the expression evaluation is copied to the function or tag.
Structures, queries, and cfobject objects are passed as references to the object.
If the tag or function gets a copy of the calling page's data, changes to the variable in the custom tag or function do not change the value of the variable on the calling page. If the variable is passed by reference, changes to the variable in the custom tag or function also change the value of the variable in the calling page.
To pass a variable to a custom tag, you must enclose the variable name in number signs. To pass a variable to a function, do not enclose the variable name in number signs.
I'm not sure I follow your question, so I'll toss out some possibly relevant information.
The syntax that you typed will work.
In the input.cfm file, you would reference Attributes.id. The value of which would be "mytag".
I would suggest using cfparam to set up a default value.
<cfparam name="Attributes.id" type="string" default="tag">
for example.
If you want to pass in the "mytag" structure instead of the string "mytag" then you would use the following sytax:
<cf_input id="#mytag#">
That would allow you to get the color using Attributes.mytag.bordercolor.
In which case, your cfparam would be more like:
<cfparam name="Attributes.id" default="#StructNew()#">
If you are wanting to pass in the string, but still get the color from the variables scope of the page then it would be something like this:
<cfif StructKeyExists(Caller,Attributes.id) AND StructKeyExists(Caller[Attributes.id],"bordercolor")>
<cfset Variables.bordercolor = Caller[Attributes.id].bordercolor>
</cfif>
This is because the variables scope of the calling page is available within the custom tag as "Caller" scope. I would advise being careful in using this, however, as you are breaking encapsulation. If you are reaching out to variable names that are specifically passed in that is probably OK, but it wouldn't generally be a good idea to get non-specified variables from Caller scope.
Postman's documentation leaves a lot to be desired. In their Variables page they say:
The following scopes are available to you:
Global
Environment
Local
Data
There's information about the Global and Environment scopes, and I believe the "Data" scope is the data from a collection run. But what are the "local" variables?
Because I'd love to have a variable that is calculated on the fly, used for the request, and then discarded. Both global and environment variables are persistent.
According to the Postman Quick Reference Guide local variables are only available within the request (or collection run) that has set them. So they are used for the request or collection run and then discarded.
When to use:
passing data from the pre-request script to the request or tests or between requests.
The behavior is a bit different in Postman vs Collection Runner / Newman, so make sure you understand how they work before using!
Setting
pm.variables.set('myVariable', MY_VALUE);
Getting
pm.variables.get('myVariable', MY_VALUE);
Removing
Local variables are automatically removed once the tests have been executed / collection run finished.
Local variables are the one you use in your Tests part.
You may even use the 'let' declaration as it is coded in javascript ...
ie:
let jsonData;
jsonData = JSON.parse(responseBody);
or use var for declaration.
var jsonData = JSON.parse(responseBody);
Though, you can erase globals on the fly using
pm.environment/global.unset(<variable>)
see here for details