-
Notifications
You must be signed in to change notification settings - Fork 446
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
Basic Less types for plugin authors (Quick Reference Card) #446
Comments
Is this something to address/fix in less.js then? |
Yes. Two alternative methods (though the details to be determined in process as always):
new Quoted("'foo'") -> 'foo'
new Quoted('"foo"') -> "foo"
new Quoted("foo") -> foo
new Quoted("'", 'foo') -> 'foo'
new Quoted('"', 'foo') -> "foo"
new Quoted('', 'foo') -> foo Both variants are OK I guess (for me the first one looks a bit more clean from the code-base point of view). |
Yeah, the first one looks better. We should really examine all the node parameters before we release a public API. OR we have a public API that is abstracted from the private one, which is totally doable. Technically |
Yes, sure we can abstract the creation of these objects but it's still more code about working with the objects rather than simply creating them from a JS-values (so at worst it still will have to look like this, though the topmost dreadful thing remains to be the numerator/denominator goody of the |
@seven-phases-max The nice part is that with the "late parsing" strategy I did in 3.0, there's now some groundwork to parse whenever you want while creating nodes, so node creation can be fairly simple if you want it to be. |
I understand I just remarked that the API is not just about creating objects. So if some |
Right, I get you. |
Posting this WIP here (per discussion at less/less.js@809dc50)
12.34
new Dimension(12.34)
42px
new Dimension(42, 'px')
left
new Keyword('left')
background-color
new Keyword('background-color')
"Hello, World!"
new Quoted('', '"Hello, World!"')
see [1]'Hello, World!'
new Quoted('', "'Hello, World!'")
see [1]true
new Keyword('true')
false
new Keyword('false')
see [2]#369
new Color('369')
rgba(11, 22, 33, 0.5)
new Color([11, 22, 33], .5)
red
Color.fromKeyword('red')
foo, 42
new Value([new Keyword('foo'), new Dimension(42)])
foo 42
new Expression([new Keyword('foo'), new Dimension(42)])
~'foo$bar .baz'
new Anonymous('foo$bar .baz')
e('#$@&%*!')
new Anonymous('#$@&%*!')
Notes:
Quoted
constructor is definitely broken, it does not do what you expect by looking at its code (the first parameter is in fact never used most likely because of latereval
code involving onlycontent/value
value).when
guards (so far they are the only statement where boolean values do matter) anything butKeyword('true')
counts asfalse
.The text was updated successfully, but these errors were encountered: