Using variables with susy-breakpoint in susy 2 - susy-compass

I have recently upgraded to Susy2 and having to rework my base templates with new susy-breakpoints instead of at-breakpoint.
With the new susy-breakpoint I need to define a breakpoint and a layout for the short hand like so "60em, 12" and I have tried storing this in a variable e.g. "$large" so that I can pass it into various classes.
However as it is a single variable the mixin only sees it as one value so I can only store one value. Is there a way two store both values in a variable?

Yep. Sass has Variable Arguments which are great for handling this situation:
#include susy-breakpoint($large...) {
// Your code here
}
The ... does the magic.

Related

How do you extend a library created variable in onvif python?

onvif python will create base variables from WSDL but not the optional elements. How do I add the optional variables to the existing definition?
as in a = create(sometype)
This defines the elements a.b and a.c.
I need to add elements a.c.d, a.c.e.g and a.c.e.h.
The short answer: It depends on what the existing variable is.
The longer answer: Since the existing variable is defined by a third party library with little to no visibility, run the code under a debugger that will tell you what the existing variable is, e.g, list, dict, etc. From that information look in the python documentation if you are not familiar with that type of variable.

Free-format prototype with variables already defined?

I have an RPGLE program that I'm trying to convert from fixed-format to free-format. In general, I know that defining entry variables is done using prototypes like so:
dcl-pr myprogram;
I#Entry1 char(5);
end-pr;
dcl-pi myprogram;
InEntry1 char(5);
end-pi;
But what I don't know is how to do this when the field is already defined. We have a standard definitions file that we copy into programs such as the one I am writing, which has the field I'm using as the enter variable already defined and copied in. In fixed-format, this is just
C *Entry PList
C Parm InEntry1
I have already tried just doing the copy before the prototype entry and leaving the specification blank, but that caused errors. I know I could just use the 'LIKE' keyword and change the variable names, but for readability's sake I would prefer to avoid doing that, and I don't know what problems that may cause down the road.
Just in case it's necessary, there are two variables I'm trying to get in: a data structure and a zoned decimal.
How can I use a variable that is already defined as an entry variable in free-format RPGLE, whether using prototypes or some other way that I do not know of?
The "right" way to handle this would be to create a new version of your standard definitions file (StdDefs==>StdDefs2) to declare the variables under a new name (perhaps with a _t suffix) and the TEMPLATE keyword.
Then in your refactored PR/PI, you use LIKE or LIKEDS.
so your original program looks somthing like
/copy StdDefs
C *Entry PList
C Parm InEntry1
Your refactored one with PR/PI looks like
/copy StdDefs2
/copy Mypr
dcl-pi myprogram;
InEntry1 like(inEntry_t);
end-pi;
Note that best practice is to have the PR in a separate member that's /COPY'd into both caller and callee.
Could not find a solution without declaring another variable with like. And assign the new variable to the old at the begenning of the program, and vice versa at the end.

JMeter functions and variables

I'm new to JMeter so this question may sound absolutely dumb...
I have a loop in which a variable (let's say it is called "raw") is being changed and written to file every iteration. The variable contains HTML encoded text so it has to be converted into plain text. I found out this can be done using __unescapeHtml function. When I tried using it worked but I ended up always receiving the same text as on the first iteration. Then I learned that I have to use vars.get instead of ${} to access a variable. So I changed ${__unescapeHtml("${raw}")} to ${__unescapeHtml(vars.get("raw")} which kind of helped: vars.get is getting the new value of raw each iteration but __unescapeHtml didn't work at all now - it just returns the encoded text from raw. I didn't succeded finding anything about this exact problem so I'm kind of stuck.
Ended up using
import org.apache.commons.lang3.StringEscapeUtils
...
StringEscapeUtils.unescapeHtml4(vars.get("raw"))
Don't know if it is a good way to do this but at least it works.
I assume, that you are using the expression ${...} inside a JSR-223 sampler or similar context. The user manual for JSR-223 Sampler states, that those scripts can be cached by JMeter. That is why you only get the values from the first time the context gets created.
The same is true for simple variable evaluations as ${varname}, as for function calls like ${__unescapeHtml(...)}.
The solution here is:
don't use ${...} inside of JSR-223 contexts, that might be cached.
you can however pass those expressions (${...}) into the context by using them as parameters through the input labeled Parameters on the JSR-223 Sampler – again assuming, that you are using it.
you can use the features, that your chosen JSR-223 context gives you, as you have done, by using the StringEscapeUtils#unescapeHtml4

Using variables in Gradle build script

I am using Gradle in my project. I have a task for doing some extra configuration with my war. I need to build a string to use in my task like, lets say I have:
task extraStuff{
doStuff 'org.springframework:spring-web:3.0.6.RELEASE#war'
}
This works fine. What I need to do is define version (actually already defined in properties file) and use this in the task like:
springVersion=3.0.6.RELEASE
task extraStuff{
doStuff 'org.springframework:spring-web:${springVersion}#war'
}
My problem is spring version is not recognised as variable. So how can I pass it inside the string?
If you're developing an Android application using Gradle, you can declare a variable (i.e holding a dependency version) thanks to the keyword def like below:
def version = '1.2'
dependencies {
compile "groupId:artifactId:${version}"
}
I think the problem may lay on string literal delimiters:
The string literals are defined exactly as in groovy so enclose it in single or double quotes (e.g. "3.0.6.RELEASE");
Gstrings are not parsed in single quotes strings (both single '...' or triple '''...''' ones) if i recall correctly;
So the code will be:
springVersion = '3.0.6.RELEASE' //or with double quotes "..."
task extraStuff{
doStuff "org.springframework:spring-web:${springVersion}#war"
}
On android there are actually 2 possibilities how to achieve this. It really depends which suits your needs. Those two possibilities have their pros and cons. You can use def variable or ext{} block. Variable def is awesome because it lets you click on the variable and points exactly where it is defined in the file compared to ext{} block which does NOT points to that exact variable. On the other hand ext{} has one good advantage and that is you can refer variables from project_name/build.gradle to project_name/app/build.gradle which in some cases is very useful BUT as I said if you click on that variable lets say only inside only one file it wont points out to the definition of that variable which is very bad because it takes you more search time if your dependency list grows.
1) def option which is propably best and saves you search time.
def lifecycle = '2.0.0'
dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:$lifecycle'
}
2) second ext{} block. Its kinda ok if dependency list is not huge.
ext {
lifecycle = '1.1.1'
}
dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:$lifecycle'
}
3) In some cases if you want to share variables between project_name/build.gradle and project_name/app/build.gradle use ext{}
in project_name/build.gradle you define kotlin_shared_variable:
buildscript {
ext.kotlin_shared_variable = '1.3.41'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_shared_variable"
}
}
which you can use in project_name/app/build.gradle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_shared_variable"
}
and of course you can combine them.
see here.
Double-quoted strings are plain java.lang.String if there’s no interpolated expression, but are groovy.lang.GString instances if interpolation is present.
Gradle uses Groovy as a DSL. Here "${springVersion}" is a placeholder, what you want is to interpolate, so you should use the double quote, only the double quote in GString has the capability to interpolate.
You can also define variables in the gradle.properties file at the root of your project. You don't have to use double quotes in that file. You would need to add the following line:
lifecycle=2.0.0

expression engine dynamic variable names: {slide_{index}_title}

I am using a simple looping plugin so that my template looks like this:
{exp:loop_plus start="1" end="4" increment="1"}
<h3>{slide_{index}_title}</h3>
{/exp:loop_plus}
However, I am ending up with the following output:
<h3>{slide_1_title}</h3>
<h3>{slide_2_title}</h3>
<h3>{slide_3_title}</h3>
<h3>{slide_4_title}</h3>
Is there any way I can have dynamic variable names like this? I am not looking for alternative methods for building a slider, I simply would like to know if the dynamic variable names like this is possible. Thanks!
I'm assuming that Loop Plus (http://devot-ee.com/add-ons/loop-plus) sets the {index} part, so the question is what is defining {slide_1_title}...?
Assuming you have an entry field or variable with this defined, what you have is correct, but if it's not working, it means there's a parsing order issue.
Let's assume the code you supplied is wrapped in a {exp:channel:entries} tag pair, what happens is EE will try to parse the variable first, so will see: {slide_{index}_title} which doesn't exist. The {exp:loop_plus} add-on will then parse it, converting it to {slide_1_title} (but to late as channel:entries has already tried to parse it), which is what is finally output to the template.
So what you want to ensure is that EE parses {exp:loop_plus} before {exp:channel:entries}, do this using parse="inward" tag:
{exp:loop_plus start="1" end="4" increment="1" parse="inward"}
<h3>{slide_{index}_title}</h3>
{/exp:loop_plus}
This is a global EE parameter that EE uses to control parse order - you won't find it documented under the specific add-on. By adding the parameter, it means this child tag will get parsed before it's parent.
One way you could do it is to declare a preload_replace variable in your template and use it in your custom field name.
So something like:
{preload_replace:my_var_prefix="whatever"}
And then in your loop, you could then use:
{slide_{my_var_prefix}_title}

Resources