|
@@ -38,6 +38,8 @@ namespace Util
|
|
|
templateString = templateString.Replace("<<ym:" + key + ">>", "");
|
|
templateString = templateString.Replace("<<ym:" + key + ">>", "");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ templateString = PublicMake(templateString, "-top2");
|
|
|
|
|
+ templateString = PublicMake(templateString, "-top");
|
|
|
templateString = PublicMake(templateString);
|
|
templateString = PublicMake(templateString);
|
|
|
return templateString;
|
|
return templateString;
|
|
|
}
|
|
}
|
|
@@ -210,25 +212,25 @@ namespace Util
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
#region 公共标签处理
|
|
#region 公共标签处理
|
|
|
- public static string PublicMake(string content)
|
|
|
|
|
|
|
+ public static string PublicMake(string content, string level = "")
|
|
|
{
|
|
{
|
|
|
- MatchCollection mc = Regex.Matches(content, "<<ym-if:.*?>>[\\s\\S]*?<</ym-if>>");
|
|
|
|
|
|
|
+ MatchCollection mc = Regex.Matches(content, "<<ym-if" + level + ":.*?>>[\\s\\S]*?<</ym-if" + level + ">>");
|
|
|
foreach (Match m in mc)
|
|
foreach (Match m in mc)
|
|
|
{
|
|
{
|
|
|
string matchValue = m.Value;
|
|
string matchValue = m.Value;
|
|
|
- Match head = Regex.Match(matchValue.Replace("<</ym-if>>", ""), "<<ym-if:.*?>>");
|
|
|
|
|
|
|
+ Match head = Regex.Match(matchValue.Replace("<</ym-if" + level + ">>", ""), "<<ym-if" + level + ":.*?>>");
|
|
|
if (head.Success)
|
|
if (head.Success)
|
|
|
{
|
|
{
|
|
|
string headValue = head.Value;
|
|
string headValue = head.Value;
|
|
|
- string resultValue = matchValue.Replace(headValue, "").Replace("<</ym-if>>", "");
|
|
|
|
|
|
|
+ string resultValue = matchValue.Replace(headValue, "").Replace("<</ym-if" + level + ">>", "");
|
|
|
string elseValue = "";
|
|
string elseValue = "";
|
|
|
- if (resultValue.Contains("<<ym-else>>"))
|
|
|
|
|
|
|
+ if (resultValue.Contains("<<ym-else" + level + ">>"))
|
|
|
{
|
|
{
|
|
|
- string[] valueData = resultValue.Split(new string[] { "<<ym-else>>" }, StringSplitOptions.None);
|
|
|
|
|
|
|
+ string[] valueData = resultValue.Split(new string[] { "<<ym-else" + level + ">>" }, StringSplitOptions.None);
|
|
|
resultValue = valueData[0];
|
|
resultValue = valueData[0];
|
|
|
elseValue = valueData[1];
|
|
elseValue = valueData[1];
|
|
|
}
|
|
}
|
|
|
- string condition = headValue.Substring(8, headValue.Length - 10);
|
|
|
|
|
|
|
+ string condition = headValue.Substring(8 + level.Length, headValue.Length - 10 - level.Length);
|
|
|
condition = condition.Replace("isEmpty", "IsNullOrEmpty");
|
|
condition = condition.Replace("isEmpty", "IsNullOrEmpty");
|
|
|
condition = condition.Replace("start(", "StartsWith(");
|
|
condition = condition.Replace("start(", "StartsWith(");
|
|
|
condition = condition.Replace("True", "true");
|
|
condition = condition.Replace("True", "true");
|
|
@@ -255,7 +257,7 @@ namespace Util
|
|
|
string jsonObjString = jsonObj.ToJson();
|
|
string jsonObjString = jsonObj.ToJson();
|
|
|
if (keyArr.Length == 1)
|
|
if (keyArr.Length == 1)
|
|
|
{
|
|
{
|
|
|
- if (jsonObjString.Contains("\"" + key + "\""))
|
|
|
|
|
|
|
+ if (jsonObjString.Contains("\"" + key + "\"") && jsonObj.Keys.Contains(key))
|
|
|
{
|
|
{
|
|
|
templateString = templateString.Replace(matchValue, jsonObj[key].ToString());
|
|
templateString = templateString.Replace(matchValue, jsonObj[key].ToString());
|
|
|
}
|
|
}
|