Learn R Programming

sass (version 0.4.9)

as_sass: Convert an R object into Sass code

Description

Converts multiple types of inputs to a single Sass input string for sass().

Usage

as_sass(input)

Value

a single character value to be supplied to sass().

Arguments

input

Any of the following:

  • A character vector containing Sass code.

  • A named list containing variable names and values.

  • A sass_file(), sass_layer(), and/or sass_bundle().

  • A list() containing any of the above.

References

https://sass-lang.com/documentation/at-rules/import

Examples

Run this code
# Example of regular Sass input
as_sass("body { color: \"blue\"; }")

# There is support for adding variables
as_sass(
  list(
    list(color = "blue"),
   "body { color: $color; }"
   )
)

# \donttest{
# Add a file name
someFile <- tempfile("variables")

# Overwrite color to red
write("$color: \"red\";", someFile)

input <-
  as_sass(
    list(
      list(color = "blue"),
      sass_file(someFile),
      "body { color: $color; }"
      )
   )

input

# The final body color is red
sass(input)
# }

Run the code above in your browser using DataLab