absurd icon indicating copy to clipboard operation
absurd copied to clipboard

.compile to/should support string compilation?

Open tunnckoCore opened this issue 11 years ago • 7 comments

How to compile from given CSS string?

body {
  cf: 'all';
  p {
    cf: 'before';
  }
  section {
    cf: 'after';
  }
}
.content {
  p {
    moveto: '10/20/30';
  },
  .animation {
    animate: 'fadeInLeftBig';
    fl: 'right';
  }
}

it seems that there's no such feature and also the api is not so node-way-friendly like here api.compile(function(){}, {minify: true}), which should be used to if you want to compile synchronously and give options

move all callbacks to the end. it is hard job to promisify the api.

tunnckoCore avatar Apr 11 '15 03:04 tunnckoCore

hmm.. ooookey, logic. it is .importCSS but it only expects 1) already expanded css (I mean it should be expended if it is nested) 2) valid css.

tunnckoCore avatar Apr 11 '15 03:04 tunnckoCore

Yep, you are right. There is no easy way to support that SCSS-ish syntax. Maybe if there is some SCSS to JSON parser.

krasimir avatar Apr 13 '15 09:04 krasimir

if I have

css = {...}
Absurd().add(css).compile();

where do I put `{minify: true}'?

offthegrass avatar Apr 23 '15 20:04 offthegrass

@offthegrass you should pass minify: true to the compile method. For example:

.compile(function() {
  // ...
}, { minify: true });

krasimir avatar Apr 23 '15 20:04 krasimir

Yea, this callback-first is confusing. We should change this api :)

tunnckoCore avatar Apr 23 '15 22:04 tunnckoCore

Yep, I wonder why I did it that way. I'll leave this issue open so I can take care.

krasimir avatar Apr 24 '15 05:04 krasimir

cool, thanks.

I'm using a package that's written in coffeescript, so I js2.coffee'd - here's how it comes out:

api.compile (->), minify: true

it works, but wtf?! (->)

offthegrass avatar Apr 24 '15 07:04 offthegrass