Sha256: 64d826a0d4a816010bf8bdf64f26262c8c9bde37445dbbd3629b5435778ef505

Contents?: true

Size: 1.31 KB

Versions: 23

Compression:

Stored size: 1.31 KB

Contents

## Interpolation

  Stylus supports interpolation by using the `{}` characters to surround an expression, which then becomes part of the identifier. For example `-webkit-{'border' + '-radius'}` would evaluate to `-webkit-border-radius`.

 A great example use-case for this is expanding properties with vendor prefixes.

      vendor(prop, args)
        -webkit-{prop} args
        -moz-{prop} args
        {prop} args

      border-radius()
        vendor('border-radius', arguments)
      
      box-shadow()
        vendor('box-shadow', arguments)

      button
        border-radius 1px 2px / 3px 4px

yielding:

      button {
        -webkit-border-radius: 1px 2px / 3px 4px;
        -moz-border-radius: 1px 2px / 3px 4px;
        border-radius: 1px 2px / 3px 4px;
      }

## Selector Interpolation

 Interpolation works with selectors as well, for example we may iterate while assigning the `height` property for the first 5 rows in a table as shown below.

    table
      for row in 1 2 3 4 5
        tr:nth-child({row})
          height: 10px * row

yielding:

    table tr:nth-child(1) {
      height: 10px;
    }
    table tr:nth-child(2) {
      height: 20px;
    }
    table tr:nth-child(3) {
      height: 30px;
    }
    table tr:nth-child(4) {
      height: 40px;
    }
    table tr:nth-child(5) {
      height: 50px;
    }

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
stylus-source-0.22.6 vendor/docs/interpolation.md
stylus-source-0.22.5 vendor/docs/interpolation.md
stylus-source-0.22.4 vendor/docs/interpolation.md
stylus-source-0.22.3 vendor/docs/interpolation.md
stylus-source-0.22.2 vendor/docs/interpolation.md
stylus-source-0.22.1 vendor/docs/interpolation.md
stylus-source-0.22.0 vendor/docs/interpolation.md
stylus-source-0.21.2 vendor/docs/interpolation.md
stylus-source-0.21.1 vendor/docs/interpolation.md
stylus-source-0.21.0 vendor/docs/interpolation.md
stylus-source-0.20.1 vendor/docs/interpolation.md
stylus-source-0.20.0 vendor/docs/interpolation.md
stylus-source-0.19.8 vendor/docs/interpolation.md
stylus-source-0.19.7 vendor/docs/interpolation.md
stylus-source-0.19.6 vendor/docs/interpolation.md
stylus-source-0.19.5 vendor/docs/interpolation.md
stylus-source-0.19.4 vendor/docs/interpolation.md
stylus-source-0.19.3 vendor/docs/interpolation.md
stylus-source-0.19.2 vendor/docs/interpolation.md
stylus-source-0.19.1 vendor/docs/interpolation.md