【问题标题】:Convert compass to css programmatically以编程方式将指南针转换为 css
【发布时间】:2019-01-16 10:47:00
【问题描述】:

我的 ruby​​ 代码中有一个指南针样式字符串。我想把它转换成一个css字符串。我有 config.rb 的值作为哈希值。

如何通过函数调用将字符串格式的指南针转换为css(字符串)?

【问题讨论】:

    标签: ruby sass compass-sass


    【解决方案1】:

    是的,你可以做到:

    require 'sass'
    
    scss_string = '@mixin test{width: auto}; div {@include test}'
    
    print Sass::compile(scss_string)
    

    这将输出:

    div {
      width: auto; }
    

    Here you have the link to the ruby doc for this method, with information about how to customize it.

    【讨论】:

    • 那么如果你的 sass 字符串依赖于 compass 本身,即darken($color, 10%),该怎么办?使用Sass.compile 会导致导入错误,因为它不知道指南针。
    猜你喜欢
    • 2018-08-17
    • 1970-01-01
    • 2012-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 2011-09-20
    相关资源
    最近更新 更多