My Blog

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

News

Archives

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.

posted on Thursday, July 15, 2010 6:51 PM

Feedback

# re: Our extensions for HtmlTags 6/30/2011 10:07 AM smartcaveman
Thanks for posting these. They look promising. I've used MvcContrib's Fluent HTML API before, which is similar. Also, I was paging through your source I found this: https://github.com/ryanohs/HtmlTags.Extensions/blob/master/src/HtmlTags.Extensions/Constants/HtmlAttributeConstants.cs#L16

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: