2023-05-30 11:32:47 +02:00
|
|
|
|
---
|
|
|
|
|
title: "@debug"
|
|
|
|
|
introduction: >
|
2023-05-30 22:27:01 +02:00
|
|
|
|
Sometimes it’s useful to see the value of a
|
|
|
|
|
[variable](/documentation/variables) or
|
|
|
|
|
[expression](/documentation/syntax/structure#expressions) while you’re
|
|
|
|
|
developing your stylesheet. That’s what the `@debug` rule is for: it’s written
|
2023-05-30 11:32:47 +02:00
|
|
|
|
`@debug <expression>`, and it prints the value of that expression, along with
|
|
|
|
|
the filename and line number.
|
|
|
|
|
---
|
2023-05-30 22:27:01 +02:00
|
|
|
|
|
2023-05-30 11:32:47 +02:00
|
|
|
|
{% codeExample 'debug', false %}
|
2023-05-30 23:23:34 +02:00
|
|
|
|
@mixin inset-divider-offset($offset, $padding) {
|
|
|
|
|
$divider-offset: (2 * $padding) + $offset;
|
|
|
|
|
@debug "divider offset: #{$divider-offset}";
|
2023-05-30 11:32:47 +02:00
|
|
|
|
|
2023-05-30 23:23:34 +02:00
|
|
|
|
margin-left: $divider-offset;
|
|
|
|
|
width: calc(100% - #{$divider-offset});
|
|
|
|
|
}
|
|
|
|
|
===
|
|
|
|
|
@mixin inset-divider-offset($offset, $padding)
|
|
|
|
|
$divider-offset: (2 * $padding) + $offset
|
|
|
|
|
@debug "divider offset: #{$divider-offset}"
|
2023-05-30 11:32:47 +02:00
|
|
|
|
|
2023-05-30 23:23:34 +02:00
|
|
|
|
margin-left: $divider-offset
|
|
|
|
|
width: calc(100% - #{$divider-offset})
|
2023-05-30 11:32:47 +02:00
|
|
|
|
{% endcodeExample %}
|
|
|
|
|
|
2023-06-21 21:20:03 +02:00
|
|
|
|
The exact format of the debug message varies from implementation to
|
|
|
|
|
implementation. This is what it looks like in Dart Sass:
|
2023-05-30 11:32:47 +02:00
|
|
|
|
|
2023-06-21 21:20:03 +02:00
|
|
|
|
```
|
|
|
|
|
test.scss:3 Debug: divider offset: 132px
|
|
|
|
|
```
|
2023-05-30 11:32:47 +02:00
|
|
|
|
|
|
|
|
|
{% funFact %}
|
2023-05-30 23:23:34 +02:00
|
|
|
|
You can pass any value to `@debug`, not just a string! It prints the same
|
|
|
|
|
representation of that value as the [`meta.inspect()` function][].
|
2023-05-30 11:32:47 +02:00
|
|
|
|
|
2023-05-30 23:23:34 +02:00
|
|
|
|
[`meta.inspect()` function]: /documentation/modules/meta#inspect
|
2023-05-30 11:32:47 +02:00
|
|
|
|
{% endfunFact %}
|