您应该使用 dwt 将代码发布到服务器,我的意思是为每个代码创建新的 dwt,然后将代码粘贴到 dwt 中。您可以将此 dwt 与 emply 组件或资源类型组件一起使用。
或者,如果您想使用文本字段,请尝试遵循 tbb 代码。在模板末尾添加此 tbb。
public override void Transform(Engine engine, Package package)
{
Regex objExp = new Regex(@"&#\d+;", RegexOptions.IgnoreCase);
Regex objDecExp = new Regex(@"[^0-9]", RegexOptions.IgnoreCase);
this.Initialize(engine, package);
string strPackage = package.GetValue("Output");
strPackage = unescapeHTML(strPackage);
strPackage = objExp.Replace(strPackage, delegate (Match match)
{
string strInput = match.ToString();
strInput = objDecExp.Replace(strInput, "");
int intValue = Convert.ToInt32(strInput);
char strChar = (char)intValue;
return strChar.ToString();
});
strPackage = strPackage.Trim();
Item objOutput = package.CreateStringItem(ContentType.Html, strPackage);
package.PushItem("Output", objOutput);
}
private string unescapeHTML(string strInput)
{
StringBuilder strOutput = new StringBuilder(strInput);
strOutput.Replace(""", """);
strOutput.Replace(" ", " ");
strOutput.Replace("&", "&");
strOutput.Replace("'", "'");
strOutput.Replace("<", "<");
strOutput.Replace(">", ">");
strOutput.Replace("¡", "¡");
strOutput.Replace("¢", "¢");
strOutput.Replace("£", "£");
strOutput.Replace("¤", "¤");
strOutput.Replace("¥", "¥");
strOutput.Replace("¦", "¦");
strOutput.Replace("§", "§");
strOutput.Replace("¨", "¨");
strOutput.Replace("©", "©");
strOutput.Replace("ª", "ª");
strOutput.Replace("¬", "¬");
strOutput.Replace("­", "­");
strOutput.Replace("®", "®");
strOutput.Replace("¯", "¯");
strOutput.Replace("°", "°");
return strOutput.ToString();
}
}