Skip to content

Document Local Variable Scoping in Import Files #437

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

Closed
BerkeleyTrue opened this issue Mar 2, 2017 · 7 comments
Closed

Document Local Variable Scoping in Import Files #437

BerkeleyTrue opened this issue Mar 2, 2017 · 7 comments

Comments

@BerkeleyTrue
Copy link

Took me a while to figure this out and it would help others if it was explicitly documented.

&{ import "./foo.less" }

Prevents variables in foo.less from overwriting variables globally.

@seven-phases-max
Copy link
Member

seven-phases-max commented Mar 17, 2017

I'm afraid the documentation just can't house all the zillion little tips and tricks out there. If it does so the noise will sepulcher the actual reference info. So I'd say the stuff (like #21, #387 etc.) is more like a content for a book instead (not expelling of course a possibility of the docs site to host such a book ... after somebody writes it).

@seven-phases-max
Copy link
Member

seven-phases-max commented Mar 17, 2017

Closing as part of #440.

@BerkeleyTrue
Copy link
Author

Local scoping in css is becoming quite popular. I was surprised to find this was not a built in feature of the language and having to dig around issues to get this bit of information seemed nonsensical when it could be added to the documentation quite easily.

@seven-phases-max
Copy link
Member

seven-phases-max commented Mar 17, 2017

The need for the detailed scope reference section is evident (this section then should obviously mention the ability of the anonymouse ruleset, i.e. & {...}, to isolate whatever code from an outer scope). But then it has to be something more than just one quite specific example. So I'm just rewording the closing reason.

this was not a built in feature of the language

What language, Less? But the unique scope of a ruleset is its native feature (same native is the thing that the & {...} is nothing but an ordinary just unnamed ruleset, thus following all scoping rules).

it could be added to the documentation quite easily.

Ready to make a PR? (The first question from me is: what section exactly could could land in? '&', 'import', 'namespaces', 'variables scope'? By now I don't think any of them fits).

@BerkeleyTrue
Copy link
Author

this was not a built in feature of the language

By this I meant some explicit syntax. Just by looking at &{ import "./foo.less" } it isn't immediately apparent what this is doing or how I could search for this in documentation. I've documented it in our codebase in a comment but not everywhere I am using it. This could cause confusion to our future contributors, many of whom are new developers and unfamiliar with less.

If there was something like import scoped 'foo.less' or import anon 'foo.less' I could understand quite easily or search for less css import scoped and the answer would probably pop right up.

it could be added to the documentation quite easily.

Ready to make a PR?

I apologies if my previous comment came off as rude or offensive in some way. I meant no harm by it. I am of the opinion that it is best to document features that users might want to use. I don't think anyone ever complained about a language having too much documentation. I can understand that finding where to put it might be difficult but I don't think that warrants not documenting it in some official way.

My motivation for opening this issue was to prevent future less users from spending a ton of time (like I did) searching for how to scope import statements and instead spend their time actually writing code.

@matthew-dean
Copy link
Member

I agree that & { ... } should be be documented specifically for a section about isolating scope. I don't think any new syntax is needed, just a special note about that technique.

@seven-phases-max
Copy link
Member

seven-phases-max commented Mar 17, 2017

search for less css import scoped and the answer would probably pop right up.

Next time just do: http://stackoverflow.com/search?q=%5Bless%5D+scope+import.

import scoped 'foo.less' or import anon 'foo.less'

Ah, I see now what you mean by "native" . Never mind then.

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

3 participants