Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add import support #1

Open
freewind opened this issue Jul 19, 2011 · 13 comments
Open

Add import support #1

freewind opened this issue Jul 19, 2011 · 13 comments
Assignees

Comments

@freewind
Copy link

This doesn't work:

@import "common";

It's not support yet?

@jryans
Copy link
Owner

jryans commented Jul 19, 2011

That's correct, currently imports are not available. Is this the only thing blocking you from using this library? I can investigate how hard it might be to add.

@freewind
Copy link
Author

Yes, "import" is very important to reuse some css libraries( like 960.gs, blueprint ). I'm using lesscss now, which works, but very slow.

@jryans
Copy link
Owner

jryans commented Jul 19, 2011

Okay, I can take a look later today. Do you need any of the other currently unsupported features (math operations, accessors), or just imports?

@ghost ghost assigned jryans Jul 19, 2011
@freewind
Copy link
Author

I don't know yet. Since the @import is not working, my less files can't be parsing. But I did used some thing like:

/**
 * A LessCSS version of the 960 Grid System
 *
 * http://lesscss.org/
 * http://960.gs/
 */
/*********************************************************************
 * Settings                                                          *
 *********************************************************************/

/* Maximum width of the document
 ********************************/
@document_width: 1200px;

/* The gutter width
 ********************************/

@gutter: 20px;
@gutter_left: 0px;

/* Number of columns
 ********************************/

@columns: 12;

/*********************************************************************
 * Container                                                         *
 *********************************************************************/

.container() {
    width: @document_width;
    margin-left:auto;
    margin-right:auto;
}

/*********************************************************************
 * Grid                                                              *
 *********************************************************************/

@column_width: (@document_width - @gutter * @columns) / @columns;

.grid(@col:1, @change:0) {
    width: (@column_width + ((@col - 1) * (@column_width + @gutter))) + @change;
    display:inline;
    float: left;
    position: relative;
    margin-left: @gutter_left;
    margin-right: @gutter - @gutter_left;
}

@freewind
Copy link
Author

To implement @import is not hard, since official "less.js" implements it very simple: When there is a @import, include the content of that file directly. No dependency checking, cycle reference checking, or any other handling. Just include them.

@jryans
Copy link
Owner

jryans commented Jul 19, 2011

Yes, it certainly is not hard. :) We just haven't needed it yet. I'll take a look to see how hard these will be to add.

@freewind
Copy link
Author

Actually, I made a eclipse plugin. When I write in a less file, it will be converted to a css file at the same time :)

@jryans
Copy link
Owner

jryans commented Jul 19, 2011

Ah, okay, well this project is a good fit for you then. I would expect ~50ms translation time for a normal sized file.

@freewind
Copy link
Author

Thank you, I will watching it

@jryans
Copy link
Owner

jryans commented Jul 26, 2011

I hope to work on these issues later this week. Would you expect LESS files using @import to maintain an @import in the output, or to produce a single large CSS file with the concatenated output from any imports?

@freewind
Copy link
Author

I found it not that simple for @import. It's not just include that file, but also handle the invocation of methods defined in that file. For example, lib.less:

.grid(@col:1) { ... }

It's a method. It should be called and calculated and render the result, not the method itself.

So I think it will be difficult to implement a full less standard.

Or just keep it simple? Not implement those?

@jryans
Copy link
Owner

jryans commented Jul 26, 2011

Looking at official less, they appear to always output a single file, so I will plan to do so as well. Mixin usage from imported files should not be too hard to achieve.

@jryans
Copy link
Owner

jryans commented Aug 9, 2011

Another developer at our company is currently rewriting this parser, bringing it more inline with less.js. This make take a bit more time to resolve your issue, but should set us on a better path towards full compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants