/// <summary> /// Informs the LESS parser about the path to the currently processed file. /// This is done by using a custom <see cref="IPathResolver" /> implementation. /// </summary> /// <param name="lessParser">The LESS parser.</param> /// <param name="currentFilePath">The path to the currently processed file.</param> internal static void SetCurrentFilePath(this Parser lessParser, string currentFilePath) { ImportedFilePathResolver pathResolver = GetPathResolver(lessParser); pathResolver.CurrentDirectory = VirtualPathUtility.GetDirectory(currentFilePath); lessParser.FileName = currentFilePath; }
/// <summary> /// Gets the file dependencies (@imports) of the LESS file being parsed. /// </summary> /// <param name="lessEngine">The LESS engine.</param> /// <returns>An array of file references to the dependent file references.</returns> private static IEnumerable <BundleFile> GetFileDependencies(LessEngine lessEngine) { ImportedFilePathResolver pathResolver = lessEngine.Parser.GetPathResolver(); VirtualPathProvider vpp = BundleTable.VirtualPathProvider; foreach (string resolvedVirtualPath in lessEngine.GetImports().Select(pathResolver.GetFullPath)) { // the file was successfully imported, therefore no need to check before vpp.GetFile yield return(new BundleFile(resolvedVirtualPath, vpp.GetFile(resolvedVirtualPath))); } lessEngine.ResetImports(); }
/// <summary> /// Initializes a new instance of <see cref="LessVirtualFileReader" /> /// </summary> protected LessVirtualFileReader(ImportedFilePathResolver pathResolver) { PathResolver = pathResolver; }