如何使用 TagBuilder 添加没有属性名称的 HTML 属性?

问题描述

我正在使用 TagBuilder 构建输入标签。我想构建如下所示的输入标签

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

假设我已经在某个变量中有字符串 {% if MyObject.IsOkay == true %} checked="checked" {%endif%}(这是一个 Liquid 模板)

如何使用 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?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)