public void GetNextUnresolvedPartial_Partials_ReturnsPartial() { var partial = new HamlNodePartial(new HamlLine("", HamlRuleEnum.Partial, "", -1)); var rootNode = new HamlNodeDummy(); rootNode.AddChild(partial); var result = rootNode.GetNextUnresolvedPartial(); Assert.That(result, Is.EqualTo(partial)); }
// TODO - Missing tests private HamlDocument ApplyMasterPage(HamlDocument hamlDocument, HamlDocument masterPage) { if (masterPage == null) { return(hamlDocument); } HamlNodePartial partial = masterPage.GetNextUnresolvedPartial(); partial.SetDocument(hamlDocument); return(masterPage); }
public void GetNextUnresolvedPartial_PartialIsAGrandchildNode_ReturnsPartial() { var textContainerNode = new HamlNodeTextContainer(0, "Test content"); var partial = new HamlNodePartial(new HamlLine("", HamlRuleEnum.Partial, "", -1)); textContainerNode.AddChild(partial); var rootNode = new HamlNodeDummy(); rootNode.AddChild(textContainerNode); var result = rootNode.GetNextUnresolvedPartial(); Assert.That(result, Is.EqualTo(partial)); }
public void GetNextUnresolvedPartial_OneResolvedAndOneUnresolvedPartial_ReturnsCorrectPartial() { var resolvedPartial = new HamlNodePartial(new HamlLine("", HamlRuleEnum.Partial, "", -1)); resolvedPartial.SetDocument(HamlDocumentBuilder.Create()); var unresolvedPartial = new HamlNodePartial(new HamlLine("", HamlRuleEnum.Partial, "", -1)); var rootNode = new HamlNodeDummy(); rootNode.AddChild(resolvedPartial); rootNode.AddChild(unresolvedPartial); var result = rootNode.GetNextUnresolvedPartial(); Assert.That(result, Is.EqualTo(unresolvedPartial)); }
private void Walk(HamlNodePartial partial) { var content = partial.Content.Trim(); if (content == "yield") { Walk(context.MainTemplate); } else if (content.StartsWith("render ")) { int start = content.IndexOf('\'') + 1; string template = content.Substring(start, content.LastIndexOf('\'') - start); if (!template.EndsWith(".haml")) { template += ".haml"; } template = "_" + template; Walk(context.GetTemplate(template)); } }