public void LoadSimpleFile() { ExpectGetChunks("home\\simple.spark", new SendLiteralChunk()); viewFolder.Stub(x => x.HasView("home\\_global.spark")).Return(false); viewFolder.Stub(x => x.HasView("Shared\\_global.spark")).Return(false); var chunks = loader.Load("home\\simple.spark"); viewFolder.VerifyAllExpectations(); syntaxProvider.VerifyAllExpectations(); Assert.AreEqual(1, chunks.Count()); Assert.AreEqual(1, loader.GetEverythingLoaded().Count()); }
public IList <string> GetGlobalVariables() { var masterFiles = new List <string>(); GetMasterFiles(MasterFolderTypes.Shared, masterFiles); GetMasterFiles(MasterFolderTypes.Layouts, masterFiles); _viewLoader.Load(_viewPath); masterFiles.ToList().ForEach(filePath => { var type = filePath.Contains(MasterFolderTypes.Shared.ToString()) ? MasterFolderTypes.Shared : MasterFolderTypes.Layouts; _viewLoader.Load(filePath.Substring(filePath.LastIndexOf(type.ToString()))); }); var globalVariables = new List <string>(); var chunkLists = _viewLoader.GetEverythingLoaded(); chunkLists.ToList().ForEach(list => { var globals = list.Where(chunk => chunk is GlobalVariableChunk); globals.ToList().ForEach(globalVar => globalVariables.Add(((GlobalVariableChunk)globalVar).Name)); }); return(globalVariables); }
private IEnumerable <T> GetAllChunks <T>() { LoadChunks(_viewPath); var allChunks = _viewLoader.GetEverythingLoaded() .SelectMany(list => list) .Where(chunk => chunk is T).Cast <T>(); return(allChunks); }
public void LoadingEmptyShadeFile() { var viewFolder = new InMemoryViewFolder { { Path.Combine("home", "empty.shade"), "" }, }; var viewLoader = new ViewLoader { SyntaxProvider = new DefaultSyntaxProvider(ParserSettings.DefaultBehavior), ViewFolder = viewFolder }; var chunks = viewLoader.Load(Path.Combine("home", "empty.shade")); var everything = viewLoader.GetEverythingLoaded(); Assert.AreEqual(1, everything.Count()); }
public void LoadingPartialInsideNamedSection() { var viewFolder = new InMemoryViewFolder { { "home\\index.spark", "<for each='var x in new[]{1,2,3}'><Guts><section:foo><Another/></section:foo></Guts></for>" }, { "home\\_Guts.spark", "<div><render:foo/></div>" }, { "home\\_Another.spark", "<p>hello world</p>" } }; var viewLoader = new ViewLoader { SyntaxProvider = new DefaultSyntaxProvider(ParserSettings.DefaultBehavior), ViewFolder = viewFolder }; var chunks = viewLoader.Load("home\\index.spark"); var everything = viewLoader.GetEverythingLoaded(); Assert.AreEqual(3, everything.Count()); }