2 using System
.Collections
.Generic
;
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
)
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
)
41 Output
.Write(string.Join(" ", attributeValues
.ToArray()));
49 Output
.Write("</{0}>", tag
);
52 public void html(ICallable block
)
54 BlockTag("html", null, block
);
57 public void text(string value)
62 public void p(ICallable 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
);