2018-09-01 22:35:20 +02:00
|
|
|
|
---
|
|
|
|
|
title: "@debug"
|
2019-03-05 01:24:31 +01:00
|
|
|
|
introduction: >
|
|
|
|
|
Sometimes it’s useful to see the value of a [variable](../variables) or
|
|
|
|
|
[expression](../syntax/structure#expressions) while you’re developing your
|
|
|
|
|
stylesheet. That’s what the `@debug` rule is for: it’s written
|
|
|
|
|
`@debug <expression>`, and it prints the value of that expression, along with
|
|
|
|
|
the filename and line number.
|
2018-09-01 22:35:20 +02:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
<% example(autogen_css: false) do %>
|
2018-10-23 22:42:40 +02:00
|
|
|
|
@mixin inset-divider-offset($offset, $padding) {
|
|
|
|
|
$divider-offset: (2 * $padding) + $offset;
|
|
|
|
|
@debug "divider offset: #{$divider-offset}";
|
|
|
|
|
|
|
|
|
|
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}"
|
|
|
|
|
|
|
|
|
|
margin-left: $divider-offset
|
|
|
|
|
width: calc(100% - #{$divider-offset})
|
2018-09-01 22:35:20 +02:00
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
The exact format of the debug message varies from implementation to
|
|
|
|
|
implementation. This is what it looks like in Dart Sass:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
test.scss:3 Debug: divider offset: 132px
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
<% fun_fact do %>
|
2018-10-23 22:42:40 +02:00
|
|
|
|
You can pass any value to `@debug`, not just a string! It prints the same
|
2019-09-03 01:32:14 +02:00
|
|
|
|
representation of that value as the [`meta.inspect()` function][].
|
2018-09-01 22:35:20 +02:00
|
|
|
|
|
2019-09-03 01:32:14 +02:00
|
|
|
|
[`meta.inspect()` function]: ../modules/meta#inspect
|
2018-09-01 22:35:20 +02:00
|
|
|
|
<% end %>
|