private string MakeAttributes(HamlNode childNode) { var attributeNode = childNode as HamlNodeHtmlAttribute; if (attributeNode == null) throw new HamlMalformedTagException("Unexpected " + childNode.GetType().FullName + " tag in AttributeCollection node"); return childNode.Content.Length > 0 ? " " + childNode.Content : ""; }
public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder) { //builder.AppendOutput(viewSourceReader.CurrentInputLine.Indent); //builder.AppendOutput(viewSourceReader.CurrentInputLine.NormalizedText); //builder.AppendOutputLine(); return EmptyClosingAction; }
public virtual void Walk(HamlNode node) { foreach (var child in node.Children) { var nodeWalker = GetNodeWalker(child.GetType()); if (nodeWalker != null) nodeWalker.Walk(child); } }
private static string HandleLeadingWhitespace(HamlNode node, string outputText) { if (node.Parent.IsLeadingWhitespaceTrimmed) { outputText = outputText.TrimStart(new[] { ' ', '\n', '\r', '\t' }); } return(outputText); }
internal void ValidateThereAreNoChildren(HamlNode node) { if (node.Children.Any()) { throw new HamlInvalidChildNodeException(node.GetType(), node.Children.First().GetType(), node.SourceFileLineNum); } }
public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder) { //var currentInputLine = viewSourceReader.CurrentInputLine; //var match = _commentRegex.Match( currentInputLine.NormalizedText ); //if( !match.Success ) //{ // SyntaxException.Throw( currentInputLine, ErrorParsingTag, currentInputLine); //} //var ieBlock = match.Groups[1].Value; //var content = match.Groups[2].Value; //var openingTag = new StringBuilder(currentInputLine.Indent); //openingTag.Append("<!--"); //var closingTag = new StringBuilder("-->"); //if( !string.IsNullOrEmpty( ieBlock ) ) //{ // openingTag.AppendFormat("{0}>",ieBlock); // closingTag.Insert(0,"<![endif]"); //} //if( string.IsNullOrEmpty( content ) ) //{ // builder.AppendOutput(openingTag.ToString()); // builder.AppendOutputLine(); // closingTag.Insert(0, currentInputLine.Indent); //} //else //{ // if( content.Length > 50 ) // { // builder.AppendOutput(openingTag.ToString()); // builder.AppendOutputLine(); // builder.AppendOutput( viewSourceReader.NextIndent ); // builder.AppendOutput(content); // builder.AppendOutputLine(); // } // else // { // builder.AppendOutput( openingTag.ToString() ); // builder.AppendOutput( content ); // closingTag.Insert(0, ' '); // } //} return () => { //builder.AppendOutput(closingTag.ToString()); builder.AppendOutputLine(); }; }
public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder) { //int currentLineIndentCount = viewSourceReader.CurrentInputLine.IndentCount; //while ((viewSourceReader.NextInputLine != null) // && (viewSourceReader.NextInputLine.IndentCount > currentLineIndentCount)) //{ // viewSourceReader.MoveNext(); //} return null; }
public override void Walk(HamlNode node) { var nodeTag = node as HamlNodeTag; if (nodeTag == null) throw new InvalidCastException("HamlNodeTagWalker requires that HamlNode object be of type HamlNodeTag."); AppendTagStart(nodeTag); AppendAttributes(nodeTag); AppendTagBodyAndClose(nodeTag); }
public override void Walk(HamlNode node) { var nodeText = node as HamlNodeText; if (nodeText == null) throw new System.InvalidCastException("HamlNodeTextWalker requires that HamlNode object be of type HamlNodeText."); _classBuilder.Append(nodeText.Indent); _classBuilder.Append(nodeText.Content); base.Walk(node); }
public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder) { //var inputLine = viewSourceReader.CurrentInputLine; //builder.AppendOutput( inputLine.Indent ); //builder.AppendCode(inputLine.NormalizedText.Trim(), options.EncodeHtml); //builder.AppendOutputLine(); return EmptyClosingAction; }
public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder) { //var code = viewSourceReader.CurrentInputLine.NormalizedText.Trim(); //if( !string.IsNullOrEmpty( code ) ) //{ // builder.AppendPreambleCode( code ); //} return EmptyClosingAction; }
public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder) { //var content = viewSourceReader.CurrentInputLine.NormalizedText.Trim().Replace( "\"", "\"\"" ); //var indexOfEquals = content.IndexOf('='); //var key = content.Substring(0, indexOfEquals).Trim(); //var value = content.Substring(indexOfEquals+1, content.Length - indexOfEquals - 1).Trim(); //builder.Meta[key] = value; return EmptyClosingAction; }
public override void Walk(HamlNode node) { var nodeText = node as HamlNodeTextContainer; if (nodeText == null) { throw new System.InvalidCastException("HamlNodeTextWalker requires that HamlNode object be of type HamlNodeText."); } RenderIndent(node, nodeText); base.Walk(node); }
public override void Walk(HamlNode node) { var nodeTag = node as HamlNodeTag; if (nodeTag == null) { throw new InvalidCastException("HamlNodeTagWalker requires that HamlNode object be of type HamlNodeTag."); } AppendTagStart(nodeTag); AppendAttributes(nodeTag); AppendTagBodyAndClose(nodeTag); }
private void RenderIndent(HamlNode node, HamlNodeTextContainer nodeText) { if (node.IsLeadingWhitespaceTrimmed) { return; } if (node.IsWhitespaceNode() && node.IsTrailingWhitespaceTrimmed) { return; } ClassBuilder.Append(nodeText.Indent); }
public override void Walk(HamlNode node) { var nodeEval = node as HamlNodeDocType; if (nodeEval == null) { throw new System.InvalidCastException("HamlNodeDocTypeWalker requires that HamlNode object be of type HamlNodeDocType."); } ClassBuilder.AppendDocType(node.Content.Trim()); ValidateThereAreNoChildren(node); }
private void MakeAttribute(HamlNode childNode) { var attributeNode = childNode as HamlNodeHtmlAttribute; if (attributeNode == null) { throw new HamlMalformedTagException("Unexpected " + childNode.GetType().FullName + " tag in AttributeCollection node", childNode.SourceFileLineNum); } var valueFragments = attributeNode.Children.Any(ch => ch is HamlNodeTextContainer) ? attributeNode.Children.First().Children : attributeNode.Children; ClassBuilder.AppendAttributeNameValuePair(attributeNode.Name, valueFragments.ToList(), attributeNode.QuoteChar); }
public override void Walk(HamlNode node) { var nodeEval = node as HamlNodeCode; if (nodeEval == null) { throw new System.InvalidCastException("HamlNodeCode requires that HamlNode object be of type HamlNodeCode."); } ClassBuilder.AppendCodeSnippet(node.Content, node.Children.Any()); base.Walk(node); if (node.Children.Any()) { ClassBuilder.RenderEndBlock(); } }
public override void Walk(HamlNode node) { var nodeText = node as HamlNodeTextLiteral; if (nodeText == null) { throw new System.InvalidCastException("HamlNodeTextLiteralWalker requires that HamlNode object be of type HamlNodeTextLiteral."); } string outputText = node.Content; outputText = HandleLeadingWhitespace(node, outputText); outputText = HandleTrailingWhitespace(node, outputText); if (outputText.Length > 0) { ClassBuilder.Append(outputText); } }
public override void Walk(HamlNode node) { var attributeCollectionNode = node as HamlNodeHtmlAttributeCollection; if (attributeCollectionNode == null) { throw new System.InvalidCastException("HamlNodeHtmlAttributeCollectionWalker requires that HamlNode object be of type HamlNodeHtmlAttributeCollection."); } foreach (HamlNodeHtmlAttribute childNode in attributeCollectionNode.Children) { if (childNode.Content.StartsWith("class=") || childNode.Content.StartsWith("id=")) { continue; } MakeAttribute(childNode); } }
public override void Walk(HamlNode node) { var nodeText = node as HamlNodeTextVariable; if (nodeText == null) { throw new InvalidCastException("HamlNodeTextVariableWalker requires that HamlNode object be of type HamlNodeTextVariable."); } string variableName = nodeText.VariableName; if (nodeText.IsVariableViewDataKey()) { ClassBuilder.AppendVariable(variableName); } else { ClassBuilder.AppendCodeToString(variableName); } }
public override void Walk(HamlNode node) { var commentNode = node as HamlNodeHtmlComment; if (commentNode == null) throw new System.InvalidCastException("HamlNodeHtmlCommentWalker requires that HamlNode object be of type HamlNodeHtmlComment."); _classBuilder.Append(node.Indent); _classBuilder.Append("<!--" + commentNode.Content); base.Walk(node); if (node.IsMultiLine) { _classBuilder.AppendNewLine(); _classBuilder.Append(node.Indent + "-->"); } else { _classBuilder.Append(" -->"); } }
public virtual void Walk(HamlNode node) { foreach (var child in node.Children) { var nodeWalker = HamlWalkerFactory.GetNodeWalker(child.GetType(), child.SourceFileLineNum, ClassBuilder, Options); if (nodeWalker == null) { continue; } try { nodeWalker.Walk(child); } catch (Exception e) { throw new HamlNodeWalkerException(child.GetType().Name, child.SourceFileLineNum, e); } } }
public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder) { //var partialName = viewSourceReader.CurrentInputLine.NormalizedText.Trim(); //if (string.IsNullOrEmpty(partialName)) //{ // if (viewSourceReader.ViewSourceQueue.Count == 0) // { // throw new InvalidOperationException(NoPartialName); // } // var templatePath = viewSourceReader.ViewSourceQueue.Dequeue(); // viewSourceReader.MergeTemplate(templatePath, true); //} //else //{ // partialName = partialName.Insert(partialName.LastIndexOf(@"\", StringComparison.OrdinalIgnoreCase) + 1, "_"); // var viewSource = options.TemplateContentProvider.GetViewSource(partialName, viewSourceReader.ViewSources); // viewSourceReader.ViewSourceModifiedChecks.Add(() => viewSource.IsModified); // viewSourceReader.MergeTemplate(viewSource, true); //} return EmptyClosingAction; }
public override void Walk(HamlNode node) { var commentNode = node as HamlNodeHtmlComment; if (commentNode == null) { throw new System.InvalidCastException("HamlNodeHtmlCommentWalker requires that HamlNode object be of type HamlNodeHtmlComment."); } ClassBuilder.Append(node.Indent); ClassBuilder.Append("<!--" + commentNode.Content); base.Walk(node); if (node.IsMultiLine) { ClassBuilder.AppendNewLine(); ClassBuilder.Append(node.Indent + "-->"); } else { ClassBuilder.Append(" -->"); } }
public abstract BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder);
private void ParseNode(HamlNode node, HamlFile hamlFile) { node.IsMultiLine = true; while ((!hamlFile.EndOfFile) && (hamlFile.CurrentLine.IndentCount > node.IndentCount)) { HamlLine nodeLine = hamlFile.CurrentLine; HamlNode childNode = GetHamlNode(nodeLine); node.Add(childNode); hamlFile.MoveNext(); if (hamlFile.EndOfFile == false) { childNode.Add(new HamlNodeText(new HamlLine("\n"))); if (hamlFile.CurrentLine.IndentCount > nodeLine.IndentCount) { ParseNode(childNode, hamlFile); } } } }
public override BlockClosingAction Render(HamlNode hamlNode, TemplateOptions options, TemplateClassBuilder builder) { //return options.TemplateCompiler.RenderSilentEval(viewSourceReader, builder); return null; }
public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder) { //var currentInputLine = viewSourceReader.CurrentInputLine; //var content = currentInputLine.NormalizedText.Trim().ToLowerInvariant(); //if (string.IsNullOrEmpty(content)) //{ // builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"); //} //else if (string.Equals(content, "1.1")) //{ // builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.1//EN"" ""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"">"); //} //else if (string.Equals(content, "strict")) //{ // builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">"); //} //else if (string.Equals(content, "frameset")) //{ // builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Frameset//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"">"); //} //else if (string.Equals(content, "html")) //{ // builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"" ""http://www.w3.org/TR/html4/loose.dtd"">"); //} //else if (string.Equals(content, "html strict")) //{ // builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01//EN"" ""http://www.w3.org/TR/html4/strict.dtd"">"); //} //else if (string.Equals(content, "html frameset")) //{ // builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Frameset//EN"" ""http://www.w3.org/TR/html4/frameset.dtd"">"); //} //else if (string.Equals(content, "mobile")) //{ // builder.AppendOutput("<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">"); //} //else if (string.Equals(content, "basic")) //{ // builder.AppendOutput("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">"); //} //else //{ // var parts = content.Split(' '); // if (string.Equals(parts[0], "xml")) // { // var encoding = "utf-8"; // if (parts.Length == 2) // { // encoding = parts[1]; // } // var invariant = Utility.FormatInvariant(@"<?xml version=""1.0"" encoding=""{0}"" ?>", encoding); // builder.AppendOutput(invariant); // } // else // { // SyntaxException.Throw(currentInputLine, ErrorParsingTag,currentInputLine); // } //} //builder.AppendOutputLine(); return EmptyClosingAction; }