grass icon indicating copy to clipboard operation
grass copied to clipboard

[feature request] "Built-in" modules

Open GoldsteinE opened this issue 3 years ago • 1 comments

Hi! I would like to be able to specify fake module "load path", which just uses in-memory &str. My use case is generating syntax highlighting CSS via syntect and then embedding it into an SCSS file, but it could also be useful for providing "standard library"-like features when embedding SCSS compiler.

GoldsteinE avatar Mar 21 '21 00:03 GoldsteinE

Currently you can configure that using Options::load_path but that still requires separate file, most likely can be done using separate file. We might need to have another file resolver if we want to have this feature, may have extra cost in complexity I believe. But internally it stores stuff as codemap::File so I guess it shouldn't be that hard?

pickfire avatar Mar 21 '21 17:03 pickfire

Hi @GoldsteinE,

I think the Fs trait may be what you're looking for. You can find a simple example of what it sounds like you're describing in our tests, https://github.com/connorskees/grass/blob/89d72015871523e4e1451545be6c3a9fd53a745b/tests/macros.rs#L114-L130

connorskees avatar Dec 24 '22 01:12 connorskees

Closing this as implemented. Please feel free to reopen this issue if you find that the Fs trait is not a sufficiently robust solution to the problem you're describing.

connorskees avatar Dec 29 '22 07:12 connorskees