Minor style changes
[castle.git] / MonoRail / Castle.MonoRail.Views.Brail / HtmlExtension.cs
blob0d3f9cfed2390c82cacbdcdbbe0431de2977765b
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.IO;
5 using System.Xml;
6 using Boo.Lang;
7 using System.Collections;
9 namespace Castle.MonoRail.Views.Brail
11 public class HtmlExtension : IDslLanguageExtension
13 readonly private TextWriter _output = null;
14 public HtmlExtension(TextWriter output)
16 _output = output;
19 public TextWriter Output
21 get { return _output; }
24 private void BlockTag(string tag, IDictionary attributes, ICallable block)
26 Output.Write("<{0}", tag);
28 List<string> attributeValues = new List<string>();
30 if (null != attributes)
32 foreach (DictionaryEntry entry in attributes)
34 attributeValues.Add(string.Format("{0}=\"{1}\"", entry.Key, entry.Value));
38 if (0 != attributeValues.Count)
40 Output.Write(" ");
41 Output.Write(string.Join(" ", attributeValues.ToArray()));
44 Output.Write(">");
45 if(block!=null)
47 block.Call(null);
49 Output.Write("</{0}>", tag);
52 public void html(ICallable block)
54 BlockTag("html", null, block);
57 public void text(string value)
59 Output.Write(value);
62 public void p(ICallable block)
64 p(null, block);
67 public void p(IDictionary attributes, ICallable block)
69 BlockTag("p", attributes, block);
72 public void Tag(string name)
74 BlockTag(name,null,null);
77 public void Tag(string name, ICallable block)
79 BlockTag(name, null, block);
82 public void Tag(string name, IDictionary attributes, ICallable block)
84 BlockTag(name, attributes,block);
87 public void Flush()
89 //no op