public override void Write(TemplateRewriterContext context) { if (IsElseIf) { context.Write("else "); } context.Write("if").ExpectSpace(); if (InvertCondition) { context.Write("!("); } context.Write(Condition); if (InvertCondition) { context.Write(")"); } context.ExpectEos(); context.Write(Then); context.Write(Else); if (!IsElseIf) { context.ExpectEnd(); } }
public override void Write(TemplateRewriterContext context) { context.Write("case").ExpectSpace(); context.Write(Value).ExpectEos(); context.Write(Body); context.ExpectEnd(); }
public override void Write(TemplateRewriterContext context) { foreach (var scriptStatement in Statements) { context.Write(scriptStatement); } }
public override void Write(TemplateRewriterContext context) { if (Text == null) { return; } if (EscapeCount > 0) { context.WriteEnterCode(EscapeCount); } // TODO: handle escape var length = Span.End.Offset - Span.Start.Offset + 1; if (length > 0) { context.Write(Text.Substring(Span.Start.Offset, length)); } if (EscapeCount > 0) { context.WriteExitCode(EscapeCount); } }
public override void Write(TemplateRewriterContext context) { context.Write("when").ExpectSpace(); context.WriteListWithCommas(Values); context.ExpectEos(); context.Write(Body); context.Write(Next); }
public override void Write(TemplateRewriterContext context) { context.Write("wrap").ExpectSpace(); context.Write(Target); context.ExpectEos(); context.Write(Body); context.ExpectEnd(); }
public override void Write(TemplateRewriterContext context) { context.Write("with").ExpectSpace(); context.Write(Name); context.ExpectEos(); context.Write(Body); context.ExpectEnd(); }
public override void Write(TemplateRewriterContext context) { context.Write("while").ExpectSpace(); context.Write(Condition); context.ExpectEos(); context.Write(Body); context.ExpectEnd(); }
public override void Write(TemplateRewriterContext context) { context.Write(Target); foreach (var scriptExpression in Arguments) { context.ExpectSpace(); context.Write(scriptExpression); } }
/// <summary> /// Converts back this template to a textual representation. This is the inverse of <see cref="Parse"/>. /// </summary> /// <param name="options">The rendering options</param> /// <returns>The template converted back to a textual representation of the template</returns> public string ToText(TemplateRewriterOptions options = default(TemplateRewriterOptions)) { CheckErrors(); var writer = new TextWriterOutput(); var renderContext = new TemplateRewriterContext(writer, options); renderContext.Write(Page); return(writer.ToString()); }
public override void Write(TemplateRewriterContext context) { if (Name != null) { context.Write("func").ExpectSpace(); context.Write(Name); } context.ExpectEos(); context.Write(Body); context.ExpectEnd(); }
public override void Write(TemplateRewriterContext context) { context.Write("tablerow").ExpectSpace(); context.Write(Variable).ExpectSpace(); context.Write("in").ExpectSpace(); context.Write(Iterator); context.Write(NamedArguments); context.ExpectEos(); context.Write(Body); context.ExpectEnd(); }
public override void Write(TemplateRewriterContext context) { if (context.IsInWhileLoop) { // TODO: Not efficient context.Write(ToString().Replace("for", "while")); } else { base.Write(context); } }
public static void Write(this TemplateRewriterContext context, List <ScriptNamedArgument> parameters) { if (parameters == null) { return; } for (var i = 0; i < parameters.Count; i++) { var option = parameters[i]; context.ExpectSpace(); context.Write(option); } }
public override void Write(TemplateRewriterContext context) { if (Name == null) { return; } context.Write(Name); if (Value != null) { context.Write(":"); context.Write(Value); } }
public override void Write(TemplateRewriterContext context) { context.Write("for").ExpectSpace(); context.Write(Variable).ExpectSpace(); if (!context.PreviousHasSpace) { context.Write(" "); } context.Write("in").ExpectSpace(); context.Write(Iterator); context.Write(NamedArguments); context.ExpectEos(); context.Write(Body); context.ExpectEnd(); }
public override void Write(TemplateRewriterContext context) { context.Write(Left); // Because a-b is a variable name, we need to transform binary op a-b to a - b if (Operator == ScriptBinaryOperator.Substract && !context.PreviousHasSpace) { context.Write(" "); } context.Write(Operator.ToText()); if (Operator == ScriptBinaryOperator.Substract) { context.ExpectSpace(); } context.Write(Right); }
public override void Write(TemplateRewriterContext context) { context.Write(Target); var isSpecialArgumentsArray = Equals(Target, ScriptVariable.Arguments) && Index is ScriptLiteral && ((ScriptLiteral)Index).IsPositiveInteger(); if (!isSpecialArgumentsArray) { context.Write("["); } context.Write(Index); if (!isSpecialArgumentsArray) { context.Write("]"); } }
public override void Write(TemplateRewriterContext context) { context.Write("{"); bool isAfterFirst = false; foreach (var member in Members) { if (isAfterFirst) { context.Write(","); } context.Write(member.Key); context.Write(":"); context.Write(member.Value); // If the value didn't have any Comma Trivia, we can emit it isAfterFirst = !member.Value.HasTrivia(ScriptTriviaType.Comma, false); } context.Write("}"); }
public void Write(TemplateRewriterContext context) { var rawText = ToString(); bool isRawComment = Type == ScriptTriviaType.CommentMulti && !rawText.StartsWith("##"); if (isRawComment) { // Escape any # by \# rawText = rawText.Replace("#", "\\#"); // Escape any }} rawText = rawText.Replace("}", "\\}"); context.Write("## "); } context.Write(rawText); if (isRawComment) { context.Write(" ##"); } }
public override void Write(TemplateRewriterContext context) { context.Write("continue").ExpectEos(); }
public override void Write(TemplateRewriterContext context) { context.Write("do").ExpectSpace(); context.Write(Function); }
public override void Write(TemplateRewriterContext context) { context.Write(Body); }
public override void Write(TemplateRewriterContext context) { context.Write(Target); context.Write(".empty?"); }
public override void Write(TemplateRewriterContext context) { context.Write("import").ExpectSpace(); context.Write(Expression); context.ExpectEos(); }
public override void Write(TemplateRewriterContext context) { context.Write(ToString()); }
public override void Write(TemplateRewriterContext context) { context.Write("this"); }
public override void Write(TemplateRewriterContext context) { }
public override void Write(TemplateRewriterContext context) { context.Write("readonly").ExpectSpace(); context.Write(Variable); context.ExpectEos(); }
public override void Write(TemplateRewriterContext context) { context.Write("else").ExpectEos(); context.Write(Body); context.Write(Else); }