Sha256: 20356236c664daec786a241a9db914d4d60c895c1a58c18db1bca7acb0c0e979

Contents?: true

Size: 947 Bytes

Versions: 23

Compression:

Stored size: 947 Bytes

Contents

## Introspection API

 Stylus supports an introspection API, allowing mixins and functions to reflect relative to the caller etc.


## mixin

  The `mixin` local variable is automatically assigned within function bodies,
  containing the string "root" indicating the function is called at the root
  level, or "block" indicating otherwise, and finally `false` if the function
  is invoked expecting a return value.

  In the following example we define `reset()` altering its behaviour when mixed in to root, another block, or a return value as used in the `foo` property below. 

      reset()
        if mixin == 'root'
          got
            root true
        else if mixin
          got 'a mixin'
        else
          'not a mixin'

      reset()

      body
        reset()
        foo reset()

compiles to:

        got {
          root: true;
        }
        body {
          foo: "not a mixin";
          got: "a mixin";
        }

Version data entries

23 entries across 23 versions & 1 rubygems

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