krasimir / absurd

A JavaScript library with superpowers
http://absurdjs.krasimirtsonev.com/
MIT License
1.38k stars 90 forks source link

.compile to/should support string compilation? #119

Open tunnckoCore opened 9 years ago

tunnckoCore commented 9 years ago

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 commented 9 years ago

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.

krasimir commented 9 years ago

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

offthegrass commented 9 years ago

if I have

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

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

krasimir commented 9 years ago

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

.compile(function() {
  // ...
}, { minify: true });
tunnckoCore commented 9 years ago

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

krasimir commented 9 years ago

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

offthegrass commented 9 years ago

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?! (->)