Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to as_sass semantics #8

Open
jcheng5 opened this issue Oct 18, 2018 · 3 comments
Open

Tweaks to as_sass semantics #8

jcheng5 opened this issue Oct 18, 2018 · 3 comments

Comments

@jcheng5
Copy link
Member

jcheng5 commented Oct 18, 2018

It's really cool that sass() allows nested unnamed lists! I would like to make this work:

sass(
  list(
    if (use_theme) theme_options, # A named list
    bootstrap_dependencies, # A list of sass_files
    custom_sass # A string
  )
)

This almost works now, but not if use_theme is FALSE. This is because anywhere a NULL is found, it turns into "null":

> as_sass(list(
+   NULL,
+   list(foo = NULL),
+   list(bar = list(NULL))
+ ))
/* Sass */
null
$foo: null;
$bar: null;

My position is that the first NULL should render as empty string, and the list(foo=NULL) should render as $foo: null;. The third entry should render as either $bar: (null); or $bar: [null];.

Once you encounter a named list, the recursion shouldn't be via as_sass, but something else--as_sass_value perhaps?

object as_sass as_sass_value
NULL "" "null"
Unnamed list Recurse with as_sass, collapse with "\n" Recurse with as_sass_value, then create (bracketed?) Sass list
Named list Recurse with as_sass_value, turn into name/value pairs Recurse with as_sass_value, turn into Sass map
Numeric, logical Throw error Convert to string
String Identity Identity
@schloerke
Copy link
Collaborator

Looks good to me!

Link for understanding sass list spec (unnamed list): https://www.sitepoint.com/sass-reference/lists/

$list: ('foo', 'bar', 'baz');

Link for understanding sass map spec (named list): https://webdesign.tutsplus.com/tutorials/an-introduction-to-sass-maps-usage-and-examples--cms-22184

$map: (
    key: value,
    nextkey: nextvalue
);

@schloerke
Copy link
Collaborator

... double check for brackets on grid

@rich-iannone
Copy link
Member

@jcheng5 should this change be done for the CRAN release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants