sass-site/source/documentation/at-rules/debug.html.md.erb
Natalie Weizenbaum 029520349a Rename /documentation/functions to /documentation/modules
This hierarchy is now going to document built-in modules, which mostly
contain functions but can also contain mixins and may potentially
contain variables in the future.
2019-09-04 15:24:22 -07:00

41 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "@debug"
introduction: >
Sometimes its useful to see the value of a [variable](../variables) or
[expression](../syntax/structure#expressions) while youre developing your
stylesheet. Thats what the `@debug` rule is for: its written
`@debug <expression>`, and it prints the value of that expression, along with
the filename and line number.
---
<% example(autogen_css: false) do %>
@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})
<% 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 %>
You can pass any value to `@debug`, not just a string! It prints the same
representation of that value as the [`inspect()` function][].
[`inspect()` function]: ../modules/meta#inspect
<% end %>