Trait rsass::FileContext [−][src]
A file context manages finding and loading files.
Example
use std::collections::HashMap; use rsass::{FileContext, Error}; #[derive(Clone, Debug)] struct StaticFileContext<'a> { files: HashMap<String, &'a[u8]>, } impl<'a> FileContext for StaticFileContext<'a> { type File = &'a [u8]; fn find_file( &self, name: &str ) -> Result<Option<(Self, String, Self::File)>, Error> { if let Some(file) = self.files.get(name).map(|data| *data) { Ok(Some((self.clone(), name.to_string(), file))) } else { Ok(None) } } }
Associated Types
Loading content...Required methods
fn find_file(
&self,
url: &str
) -> Result<Option<(Self, String, Self::File)>, Error>
[src]
&self,
url: &str
) -> Result<Option<(Self, String, Self::File)>, Error>
Find a file.
If the file is imported from another file, the argument is the exact string specified in the import declaration.
The official Sass spec prescribes that files are loaded by url instead of by path to ensure universal compatibility of style sheets. This effectively mandates the use of forward slashes on all platforms.