question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

space separated values interpreted as list...

See original GitHub issue

I’m trying to write a function that takes a comma separated list of box-shadows and converts them to filter: drop-shadow.

I’m having a problem, if I pass a single shadow to my function, Stylus interprets it as an array instead of a string, and then it get parsed by the for loop.

drop-shadow($array...)
  $dropShadows = ()

  for $shadow in $array
    push($dropShadows, 'drop-shadow(' + $shadow + ')');

  filter: unquote(join(' ', $dropShadows))

drop-shadow: 0 0

$array is of type unit, but the result is:

filter: drop-shadow(0) drop-shadow(0)

Why?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Panyacommented, Jun 9, 2016

Actually 0 0 is a list from the Stylus perspective. If I understand your problem correctly, you can use list-separator bif to check if the given list is separated by comma:

drop-shadow()
  if list-separator(arguments) == ','
    $dropShadows = ()
    for $shadow in arguments
      push($dropShadows, 'drop-shadow(' + $shadow + ')');
    filter: unquote(join(' ', $dropShadows))
  else
    filter: arguments
0reactions
FezVrastacommented, Jun 9, 2016

Opened a dedicated bug for it https://github.com/stylus/stylus/issues/2196

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Convert Space-Separated String to List in Python
To convert a space-separated string to list in Python, split the string by empty space, convert a number string to int, add the...
Read more >
Change a string of integers separated by spaces to a list of int
The most simple solution is to use .split() to create a list of strings: x = x.split(). Alternatively, you can use a list...
Read more >
Convert space delimited string to a list in Python - thisPointer
Convert space delimited string to a list using split() with the strip(). The strip() method is used to remove the delimiter spaces from...
Read more >
How can I add values into a list separated by a space in Python?
First off, take the input as a raw_input() in a list nums and apply spilt() function on it: ; This line stores the...
Read more >
Need to take space separated inputs from users and put them ...
So, I want to be able to take inputs from users where users will input space separated strings or values and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found