Comments (7)
Good catch! The problem is specifically that conditionals aren't allowed inside namespaced properties. I'll fix this soon. Thanks!
from libsass.
Oh, I should also point out that replacing the background { ... }
block with the following should work (assuming that the is-url
function is implemented in SassScript, of course):
background-image: if(is-url($img), $img, image-url($img));
background: {
repeat: no-repeat;
position: $x $y;
}
from libsass.
After playing a bit with the code I tried this modification but it now gives another error:
It seems that this parser is generated by hand. How it works ?
If some explanation about of the logic of this parser is provided it can allow other people to help improve it, I plan to integrate a lua interpreter on it and knowing a bit how it is supposed to work will make things easier.
Node Document::parse_propset()
{
lex< identifier >();
Node property_segment(context.new_Node(Node::identifier, path, line, lexed));
lex< exactly<':'> >();
lex< exactly<'{'> >();
Node block(context.new_Node(Node::block, path, line, 1));
while (!lex< exactly<'}'> >()) {
if (peek< sequence< identifier, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
block << parse_propset();
}
///////new code start
else if(peek< exactly<'@'> >()) {
block << parse_block(block);
}
//////new code end
else {
block << parse_rule();
lex< exactly<';'> >();
}
}
if (block.empty()) throw_syntax_error("namespaced property cannot be empty");
Node propset(context.new_Node(Node::propset, path, line, 2));
propset << property_segment;
propset << block;
return propset;
}
from libsass.
Yeah, the parser is hand-written and somewhat complex, and the formal syntax of Sass itself is fairly complicated too. Documenting the whole thing isn't really feasible for me at the moment, but if you can tell me how you want to integrate Lua and what you want to do with it, I may be able to explain some of the relevant LibSass components.
(Incidentally, Lua is one of my favorite langauges, so I appreciate your interest in integrating it with LibSass!)
from libsass.
My idea is to be able to also create functions with lua to be used inside scss probably something like:
@-lua {
--any lua code here
--maybe having a global object sass where we can create new functions on it
--that will be searched when an identifier is not found elsewhere
function sass:resize_image(img_name, new_size)
os.execute("imagemagick ...")
...
end
}
.menu {
background-image : @include resize_image('some_image', 30px);
}
from libsass.
Hmm, rather than introduce special syntax, a better way might be to introduce a new built-in Sass function that takes a Lua source string as an argument. Check out functions.cpp
for the set of built-in Sass functions. They're also declared in functions.hpp
and registered in context.cpp
.
You could define the function to be used as follows:
$x: something();
$y: something-else();
div {
foo: lua("some_lua_function(#{$x}, #{$y})");
}
Unfortunately, defining functions in Lua and making them accessible in Sass will require a foreign function interface, which is still in development. But once this is done, you'd be able to add Lua support without needing to fork LibSass.
from libsass.
All right, directives and whatnot are allowed in namespaced properties now.
from libsass.
Related Issues (20)
- libsass.org has expired HOT 2
- SassError: media query expression must begin with '(' HOT 2
- build with autotools failed on ubuntu16.04
- extend does not extend all values
- 'There are no more files' error with Ruby 2.7..3 & Windows 7 (might be ffi related) HOT 3
- Read null address in Sass::SharedPtr::obj and Sass::Functions::sass_if HOT 2
- Read null address in Sass::Inspect::operator() HOT 1
- Is any precombiled so files for Raspberry ARM64
- can't find stylesheet to import "~@angular/material/theming"; HOT 1
- AddressSanitizer: SEGV on unknown address 0x000000000000 at inspect.cpp:466 HOT 2
- AddressSanitizer: stack-overflow on address 0x7ffff3e46ff8 (pc 0x7f13120dddd5 bp 0x615000000be8 sp 0x7ffff3e47000 T0) HOT 2
- random($limit) should no longer ignore units HOT 1
- A stack-overflow src/ast_selectors.cpp:557 in Sass::CompoundSelector::has_real_parent_ref() const HOT 7
- AddressSanitizer: stack-overflow src/ast_selectors.cpp:464 in Sass::ComplexSelector::has_placeholder() const HOT 2
- LeakSanitizer: detected memory leaks HOT 1
- LibSass not doing inplace text replacement for variables in unknown at rules HOT 2
- Ambiguous operator== overloads with GCC 13 and C++20
- Validated `or` css-operator usage does not compile in media query when included in SCSS HOT 5
- `mix(...)` sass semantics in relation to `color-mix(...)` css semantics HOT 3
- 3.6.6: compile time watnings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libsass.