我们在其中一个页面上遇到了大量的MACRORESOLVER错误,我能够确定它的来源。我们在静态html Web部件中有一个宏,如下面的代码,我无法弄清楚出了什么问题。它也按预期工作,所以我很困惑。语法错了吗?希望有人可以帮助我。
<div class="row">
<div class="col-sm-4 newsltr-two-btn">
{% if(!String.IsNullOrEmpty(Document)) { %}
<a target="_blank" href="~/getattachment/{% Document %}/attachment.aspx" download>{% DocumentText %}</a>
{% } else if (!String.IsNullOrEmpty(ExternalDocumentUrl)) { %}
<a target="_blank" href="{% ExternalDocumentUrl %}">{% DocumentText %}</a>
{% } #%}
</div>
</div>
事件簿:
评估表达式时出错:if(!string.IsNullOrEmpty(Document)){print(ResolveMacros(“\ r \ n {%DocumentText%} \ r \ n”))} else if(!string.IsNullOrEmpty(ExternalDocumentUrl)){ print(ResolveMacros(“\ r \ n {%DocumentText%} \ r \ n”))} |(用户)paulo |(哈希)7b864efc818f93934b7bfb4c7d92234dc8c506e841ed30c3b661f8bee604d86b
System.ArgumentOutOfRangeException:索引超出范围。必须是非负数且小于集合的大小。参数名称:CMS.MacroEngine.ExpressionEvaluator.EvaluateCondition的System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument参数,ExceptionResource资源)的索引(Boolean&match,Boolean&securityPassed,DataRow drLogItem,DateTime evaluationStarted)
看起来您的语法中有错误。见下面的表示法:
<div class="row">
<div class="col-sm-4 newsltr-two-btn">
{% if(!String.IsNullOrEmpty(Document)) { %}
<a target="_blank" href="~/getattachment/{% Document %}/attachment.aspx" download>{% DocumentText %</a> // your error is here, missing a closing curly brace after the percent sign for DocumentText
{% } else if (!String.IsNullOrEmpty(ExternalDocumentUrl)) { %}
<a target="_blank" href="{% ExternalDocumentUrl %}">{% DocumentText %}</a>
{% } #%}
</div>
</div>
此外,如果您使用静态HTML webpart,我建议将其移动到静态文本webpart。原因是静态文本不验证和更正您输入的任何HTML。这也可能是WYSIWYG编辑器正在修改标记并导致问题的问题。