Beispiel #1
0
 public override void ToHtml(IHtmlWriter writer)
 {
     writer.Write(Selector);
     writer.Write(" { ");
     writer.Write(Styles);
     writer.WriteLine(" }");
 }
        private void WriteHtml(IHtmlWriter html, DebugRegion region, int depth)
        {
            if (region.Element != null)
            {
                html.WriteElementLine("p", "Region inherits from '" + region.Element.Name + "' region");
                if (depth != 1)
                {
                    StartIndent(html, false);
                    WriteDebugInfo(html, region.Element.GetDebugInfo(), 2);
                    EndIndent(html);
                }
            }

            if (region.RepeatType != null)
            {
                html.WriteOpenTag("p");
                html.Write("Repeat region for each ");
                html.WriteElement("i", region.RepeatType.DisplayName());
                if (!string.IsNullOrEmpty(region.RepeatScope))
                {
                    html.Write(" in '" + region.RepeatScope + "' scope");
                }
                html.Write(" from ");
                html.WriteElement("i", region.ListType.DisplayName());
                if (!string.IsNullOrEmpty(region.ListScope))
                {
                    html.Write(" in '" + region.ListScope + "' scope");
                }
                html.WriteCloseTag("p");
            }

            if (region.Scope != null)
            {
                if (region.Scope.Scopes != null)
                {
                    html.WriteElementLine("p", "Region data scope");
                    StartIndent(html, false);
                    WriteDebugInfo(html, region.Scope, 3);
                    EndIndent(html);
                }
            }

            if (region.Children != null && region.Children.Count > 0)
            {
                html.WriteElementLine("p", "Region has contents");
                if (depth != 1)
                {
                    StartIndent(html, true);
                    WriteDebugInfo(html, region.Children[0], depth - 1);
                    EndIndent(html);
                }
            }
        }
            public override void Write(IHtmlWriter writer)
            {
                if (string.IsNullOrEmpty(Name))
                {
                    writer.Write("function (");
                }
                else if (IsPublic)
                {
                    writer.Write("var ");
                    writer.Write(Name);
                    writer.Write(" = function (");
                }
                else
                {
                    writer.Write("function ");
                    writer.Write(Name);
                    writer.Write(" (");
                }

                if (!string.IsNullOrEmpty(Parameters))
                {
                    writer.Write(Parameters);
                }

                writer.WriteLine(") {");
                writer.IndentLevel++;

                foreach (var line in Body.Replace("\r", "").Split('\n'))
                {
                    writer.WriteLine(line);
                }

                writer.IndentLevel--;
                writer.WriteLine(string.IsNullOrEmpty(Name) ? "}();" : "}");
            }
Beispiel #4
0
 public override void ToHtml(IHtmlWriter writer)
 {
     if (!string.IsNullOrEmpty(Text))
     {
         writer.Write(Text);
         writer.WriteLine();
     }
 }
            public override void Write(IHtmlWriter writer)
            {
                if (string.IsNullOrEmpty(Name))
                {
                    throw new Exception("You can not add a JavaScript class with no name");
                }

                writer.Write("var ");
                writer.Write(Name);
                writer.WriteLine(" = function () {");
                writer.IndentLevel++;

                foreach (var line in Body.Replace("\r", "").Split('\n'))
                {
                    writer.WriteLine(line);
                }

                writer.IndentLevel--;
                writer.WriteLine("}();");
            }
            public void Write(IHtmlWriter writer)
            {
                if (_elements == null)
                {
                    return;
                }

                var hasNamespace = !string.IsNullOrEmpty(NamespaceName);

                if (hasNamespace)
                {
                    writer.Write(Line1());
                    writer.Write(Line2());
                    writer.IndentLevel++;
                }

                foreach (var element in _elements)
                {
                    writer.WriteLine();
                    element.Write(writer);
                }

                if (hasNamespace)
                {
                    writer.WriteLine();

                    foreach (var element in _elements.Where(e => e.IsPublic && !string.IsNullOrEmpty(e.Name)))
                    {
                        writer.WriteLine("exported." + element.Name + " = " + element.Name + ";");
                    }

                    writer.IndentLevel--;
                    writer.WriteLine(LineN2());
                    writer.WriteLine(LineN1());
                    writer.WriteLine();
                }
            }
 public override void Write(IHtmlWriter writer)
 {
     if (string.IsNullOrEmpty(Name))
     {
         if (!string.IsNullOrEmpty(InitializationExpression))
         {
             writer.Write(InitializationExpression);
         }
     }
     else
     {
         writer.Write(string.IsNullOrEmpty(Type) ? "var" : Type);
         writer.Write(' ');
         writer.Write(Name);
         if (!string.IsNullOrEmpty(InitializationExpression))
         {
             writer.Write(" = ");
             writer.Write(InitializationExpression);
         }
     }
     writer.WriteLine(";");
 }
 public override void Write(IHtmlWriter writer)
 {
     writer.Write(Text);
     writer.WriteLine();
 }