My Blog

  Home  |   Contact  |   Syndication    |   Login
  8 Posts | 0 Stories | 17 Comments | 0 Trackbacks

News

Archives

Thursday, July 15, 2010 #

A while back I wrote about using a semantic model for HTML generation. Today I finally got around to posting our (Phoenix Web Group) extensions for Fubu's HtmlTags library online. The code can be found here.

We added a bunch of missing tags and some extention methods to help make working with nesting and tables easier. (We prefer using params parameters instead an array parameters.) We also added a single static entry point into all of the tags: the Tags class.

Here is some code using our extensions that renders a typical edit field with a label:

public static HtmlTag EditFieldFor(Type modelType, object model, PropertyInfo fieldProperty)
{
	return Tags.Div
		.AddClass("fields")
		.Nest(
			ViewConventionExtensions
				.LabelFor(modelType, model, fieldProperty)
				.AddClass("label"),
			Tags.Div
				.AddClass("field")
				.Nest(
					ViewConventionExtensions
						.InputFor(modelType, model, fieldProperty)
				)
		);
}

The real power of using HtmlTags becomes apparent when you use them with HTML input conventions which will be the topic of my next post.