Join Calculated Value to String - less

I have the following less code:
li {
#count: 6;
&:nth-child(~"{#count}n") {
}
}
I would like this result in:
li {
&:nth-child(6n) {
}
}
But I get the error "ParseError: Unrecognised input".
How can I make this work?
Thank You,
Miguel

li {
#count: 6;
&:nth-child(#{count}n) {
// ...
}
}

Related

my code print error even the input is correct

This is origin code
if (!isNullOrEmpty(configTypeBuilder.destinationField, RULE_CRITERIA_CONFIG_TYPE_BUILDER_DESTINATION_FIELD_PATH)) {
if (ruleAttributes.firstOrNull { ruleAttribute -> ruleAttribute == destinationField } == null) {
addValidationError(RULE_CRITERIA_CONFIG_TYPE_BUILDER_DESTINATION_FIELD_PATH, configTypeBuilder.destinationField, NOT_EXIST_CONSTRAINT)
}
}
I modify the code, just add the invalid value to a list, and then print them, but now when I enter valid destinationField after invalid destinationField, it will still show the error message, I don't know what's going on
val invalidDestination = hashSetOf<String>()
if (!isNullOrEmpty(configTypeBuilder.destinationField, RULE_CRITERIA_CONFIG_TYPE_BUILDER_DESTINATION_FIELD_PATH)) {
for (destinationField in destinationFieldList) {
if (!ruleAttributes.contains(destinationField)) {
invalidDestination.add(destinationField)
}
}
if (invalidDestination.size > 0) {
addValidationError(
"$RULE_CRITERIA_CONFIG_TYPE_BUILDER_DESTINATION_FIELD_PATH $NOT_EXIST_CONSTRAINT",
DESTINATION,
"$ADD_TAX_ENGINE_ATTRIBUTE_FIELDS $invalidDestination"
)
}
}
If your goal is to show error message only if there are no valid destinations, you need to add one more condition to your if statement. If not please clarify your question and post the whole function
Condition example:
var foundValid = false
for (destinationField in destinationFieldList) {
if (!ruleAttributes.contains(destinationField)) {
invalidDestination.add(destinationField)
}else {
foundValid = true
break //if you need invalidDestination list for later remove this break
}
}
if (invalidDestination.size > 0 && !foundValid) {
...
}

How to disable a graphql filter if the variable is not set?

I am working on a page with configurable filters. The graphql query looks like:
query GetPlayers(
$offset: Int
$limit: Int
$skillIds: [uuid!] = null
$playerTypeIds: [Int!] = null
$availability: Int = null
$timezones: [String!] = null
$search: String = null
) {
player(
order_by: { total_xp: desc }
offset: $offset
limit: $limit
where: {
availability_hours: { _gte: $availability }
timezone: { _in: $timezones }
player_type_id: { _in: $playerTypeIds }
Player_Skills: { Skill: { id: { _in: $skillIds } } }
_or: [
{ username: { _ilike: $search } }
{ ethereum_address: { _ilike: $search } }
]
}
) {
id
}
}
I would like the default behavior to be to return all entries. I am using Hasura 1.3.3 and null is interpreted as {} which will return all entries. The only problem is the Player_Skills: { Skill: { id: { _in: $skillIds } } } line. There is a join table with foreign keys referring to the players and skills tables, and that line will only return players who have at least one entry in that table.
Is it possible to form a query that will ignore the skills filter if $skillIds is null?

ctools table component conditional formatting

I have no idea if this is the correct forum to ask this question, but I figured I would give it a go - does anyone use Pentaho Ctools? I am trying to apply conditional formatting to column 8 of my table component, but so far no available. Any thoughts would be greatly appreciated!
function f(){
this.setAddInOptions("numeric","formattedText",function(statusReport){
var days = statusReport.value;
if(statusREport.colIndex == 8)
if(days <=30){
return { textFormat: function(v, st) { return "<span style='color:green'>"+v+"</span>"; } };
}
else {
return { textFormat: function(v, st) { return "<span style='color:red'>"+v+"</span>"; } };
}
});
}
Pre Execution Function:
function f(){
//conditional coloring of cells
this.setAddInOptions("colType","formattedText",function(cell_data){
var days = cell_data.value;
if(cell_data.colIdx == 7)
{
if(!cell_data.value) //checking the null possibility
{
this.value = '00000';
}
}
if(days > 30){
return { textFormat: function(v, st) { return "<span style='color:#FF0000'>"+v+"</span>"; } };
}
else if(days <= 30) {
return { textFormat: function(v, st) { return "<span style='color:#000000'>"+v+"</span>"; } };
}
}) ;
}
You also have to update the Column Types in Advanced Properties - make the regular column types "string" or whatever they are and change the formatted column to "formattedText".

Lex/Yacc: Code for tokenizing and parsing C source file

right now, I am studying the code below
http://www.quut.com/c/ANSI-C-grammar-l-2011.html
{L}{A}* { return check_type(); }
{HP}{H}+{IS}? { return I_CONSTANT; }
{NZ}{D}*{IS}? { return I_CONSTANT; }
"0"{O}*{IS}? { return I_CONSTANT; }
{CP}?"'"([^'\\\n]|{ES})+"'" { return I_CONSTANT; }
{D}+{E}{FS}? { return F_CONSTANT; }
{D}*"."{D}+{E}?{FS}? { return F_CONSTANT; }
{D}+"."{E}?{FS}? { return F_CONSTANT; }
{HP}{H}+{P}{FS}? { return F_CONSTANT; }
{HP}{H}*"."{H}+{P}{FS}? { return F_CONSTANT; }
{HP}{H}+"."{P}{FS}? { return F_CONSTANT; }
({SP}?\"([^"\\\n]|{ES})*\"{WS}*)+ { return STRING_LITERAL; }
I want to ask that what is the meaning of this part of the code? and how does it concern with Yacc? The Yacc code is http://www.quut.com/c/ANSI-C-grammar-y-2011.html

Passing a parameter to a Component on instantiation

I'm creating TableViewColumns during runtime and need to pass the role to the TableViewColumn.
TableView {
model: myModel
onModelChanged: {
var roleList = myModel.customRoleNames
for ( var i = 0; i < roleList.length; ++i ) {
var role = roleList[ i ]
addColumn( /* my column component here */ )
}
}
}
Component {
id: columnComponent
TableViewColumn {
role: /* ??? */
}
}
How can I feed the role to my Component when it's being instantiated?
Ok, I've got it. Here is the solution:
TableView {
id: myTableView
model: myModel
onModelChanged: {
var roleList = myModel.customRoleNames
for ( var i = 0; i < roleList.length; ++i ) {
var role = roleList[ i ]
addColumn( columnComponent.createObject ( myTableView, { "role": role } ) )
}
}
}
Component {
id: columnComponent
TableViewColumn { }
}
This, of course, works for all properties of TableViewColumn, eg.:
addColumn( columnComponent.createObject ( myTableView, { "role": myRole, "title": someTitle } ) )