Sha256: dffa1e25a03370756ba9b2657aa5e4d2d2a540bfd06098c8d5f422ec1284f813

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

== Sass

Lets say we have a Sass document called 'test.sass' containing:

  $blue: #3bbfce
  $margin: 16px

  .content-navigation
    border-color: $blue
    color: darken($blue, 9%)

  .border
    padding: $margin / 2
    margin: $margin / 2
    border-color: $blue

We can render the Sass document via #render.

  @css = Malt.render(:file=>'tmp/test.sass')

And we can verify that @css is the expected CSS:

  .content-navigation {
    border-color: #3bbfce;
    color: #2ca2af; }

  .border {
    padding: 8px;
    margin: 8px;
    border-color: #3bbfce; }

We can also get a hold of the Sass document via the Malt.file function.

  sass = Malt.file('tmp/test.sass')

  sass.class.assert == Malt::Format::Sass

We can convert the Sass document to a CSS document via the #to_css method.

  css = sass.to_css

We can see that the output is an instance of Malt::Format::HTML.

  css.class.assert == Malt::Format::CSS

And that by calling #to_s we can get the rendered CSS document.

  css.to_s.assert.include?('border-color: #3bbfce;')

Or we can convert the Sass document directly to CSS via the #css method.

  out = sass.css

  out.assert.include?('border-color: #3bbfce;')

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
malt-0.3.0 qed/03_formats/13_sass.rdoc
malt-0.2.0 qed/03_formats/13_sass.rdoc
malt-0.1.1 qed/03_formats/13_sass.rdoc