Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class FluentTagBuilder
{
public TagBuilder InnerBuilder { get; private set; }
public FluentTagBuilder(string tagName)
{
InnerBuilder = new TagBuilder(tagName);
}
public FluentTagBuilder AddCssClass(string cssClass)
{
InnerBuilder.AddCssClass(cssClass);
return this;
}
public FluentTagBuilder GenerateId(string name)
{
InnerBuilder.GenerateId(name);
return this;
}
public FluentTagBuilder MergeAttribute(string key, string value, bool replaceExisting = false)
{
InnerBuilder.MergeAttribute(key, value, replaceExisting);
return this;
}
public FluentTagBuilder MergeAttributes<TKey, TValue>(IDictionary<TKey, TValue> attributes,
bool replaceExisting = false)
{
InnerBuilder.MergeAttributes(attributes, replaceExisting);
return this;
}
public FluentTagBuilder SetInnerText(string innerText)
{
InnerBuilder.SetInnerText(innerText);
return this;
}
public override string ToString()
{
return InnerBuilder.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment