如何在 CSS 输出中启用 SASS 行号?

发布于 2024-08-13 00:57:17 字数 318 浏览 3 评论 0原文

如果我使用 SASS,如何在 CSS 输出中启用行号?我找到了一篇文章,但不太明白在哪里进行修改

http://pivotallabs.com/users/damon/blog/articles/765-standup-04-07-2009-we-have-questions#comments

可以你帮我吗?

How can I enable line numbers in CSS output if I am using SASS? I found an article but I didn't quite understand where to make the modifications

http://pivotallabs.com/users/damon/blog/articles/765-standup-04-07-2009-we-have-questions#comments

Could you help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我喜欢麦丽素 2024-08-20 00:57:17

有一个名为 :line_comments 的选项,如果将其设置为 true,Sass 会将行号放入编译的输出中。

如何设置此选项取决于您如何使用 Sass。如果它在 Rails、Merb 或 Rack 应用程序中,您可以设置 Sass::Plugin.options[:line_comments] = true

如果您使用指南针,请在配置文件中设置 line_comments = false

There's an option called :line_comments if you set this to true, Sass will place line numbers in your compiled output.

How to set this option depends on how you're using Sass. If it's in a Rails, Merb, or Rack application you can set Sass::Plugin.options[:line_comments] = true.

If you're using compass, set line_comments = false in your configuration file.

記柔刀 2024-08-20 00:57:17

如果您碰巧使用 Sprockets 和 sprockets-sass gem,您可能需要这样做这:

Sprockets::Sass.options[:line_comments] = true

If you happen to be using Sprockets and the sprockets-sass gem, you may need to do it like this:

Sprockets::Sass.options[:line_comments] = true
八巷 2024-08-20 00:57:17

有人建议这个猴子补丁:

# Had to use this instead as per comment by @glebtv https://github.com/rails/sass-rails/issues/157
module Sass
    class Engine
      def initialize(template, options={})
        @options = self.class.normalize_options(options)
        @options[:debug_info] = true
        @template = template
      end
    end
end

猴子补丁有效,但我认为这效果更好: https://github.com/rails/sass-rails/pull/181

现在,您必须从 master 分支拉入rails-sass。

group :development, :test do
  gem 'sass-rails', '~> 4.0.0', git: 'https://github.com/rails/sass-rails.git', branch: 'master'
end

Someone suggested this monkey-patch:

# Had to use this instead as per comment by @glebtv https://github.com/rails/sass-rails/issues/157
module Sass
    class Engine
      def initialize(template, options={})
        @options = self.class.normalize_options(options)
        @options[:debug_info] = true
        @template = template
      end
    end
end

The monkey-patch works, but I think this works even better: https://github.com/rails/sass-rails/pull/181

For now, you have to pull in rails-sass from the master branch.

group :development, :test do
  gem 'sass-rails', '~> 4.0.0', git: 'https://github.com/rails/sass-rails.git', branch: 'master'
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文