How to add HTML attribute without attribute name using TagBuilder?

309 views Asked by At

I am building a Input tag using TagBuilder. I want to build the input tag like below

<input name="IsOkay" type="checkbox" {% if MyObject.IsOkay == true %} checked="checked" {%endif%} />

Assume that I already have string {% if MyObject.IsOkay == true %} checked="checked" {%endif%} in some variable. (This is a Liquid template)

How do I add this string using TagBuilder?

   var tag = new TabBuilder("input");
   tag.MergeAttribute("name","IsOkay");
   tag.MergeAttribute("type","checkbox");

   var str = "{% if MyObject.IsOkay == true %} checked="checked" {%endif%}";
   
   how do I add str into tag since there will not be any attribute name?
0

There are 0 answers