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

Asset-url #1361

Closed
glebm opened this issue Aug 5, 2014 · 4 comments
Closed

Asset-url #1361

glebm opened this issue Aug 5, 2014 · 4 comments

Comments

@glebm
Copy link

glebm commented Aug 5, 2014

I would like to do something about asset-url helpers in Compass and Sprockets. They make writing and using universally compatible libraries very difficult. Example at hand is bootstrap-sass (1, 2, 3, 4, 5).

Perhaps we can use url() and delegate it to the helper automatically, instead of calling the helpers directly. For example, url("logo.png") would be the same as url(asset-path("logo.png")) in Sprockets. I've started on a pure Sass library that does this via overriding @function url($path) here: https://github.com/glebm/sass-rewrite-url.

It almost works, but can unquoted strings be processed this way?

@chriseppstein
Copy link

the url function in CSS has special parsing rules to allow it to treat the argument as a string. Sass has special handling for this, but when it's triggered it's a special string instead of a function call. @nex3 perhaps we should parse the url as a function call with an unquoted string as the argument instead of as a special string?

@nex3
Copy link
Contributor

nex3 commented Aug 13, 2014

I don't like the idea of overriding the functionality of url() at all. Sass goes to great pains to make it clear when users are writing plain versus augmented CSS, and this breaks that entirely. I also don't want to encourage people to monkey-patch external styles in the way this seems to do.

@nex3 nex3 closed this as completed Aug 13, 2014
@glebm
Copy link
Author

glebm commented Aug 13, 2014

Yeah, hidden variable is a bad solution.

If Sass had some kind of native asset-path in the core, libraries could include assets compatibly:

  background-image: url(asset-path('logo.png'));

logo.png would be resolved relative to the file and from asset load paths in pure Sass, while environments such as Sprockets could extend the load paths or even override asset-path function.

@nex3
Copy link
Contributor

nex3 commented Aug 15, 2014

Sass very explicitly avoids having any knowledge of project structure, including asset paths. This is the job of layers on top of it like Compass.

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