我正在编码一个自定义SharePoint Item_XX.html模板,该模板从我的SharePoint自定义列表中输入数据。我不确定如何“分解”脚本。如何在输出显示html的情况下使用if-else语句?
您会看到我要说的是: 如果有LogoSrc数据,请将数据添加到图像src。否则显示文本(标题字段中的dtaa)
<script> if (!LogoSrc==null){ </script>
<img src="_#= $htmlEncode(LogoSrc) =#_" />
<script> } else { </script>
<p style="font-size: 13pt; font-family: 'Malgun Gothic', Arial, sans-serif; color: #000000; font-weight: 700;">_#= Title =#_</p>
<script> } </script>
答案 0 :(得分:1)
SharePoint Item_XX.html文件需要特定的脚本语法。解决方案是:
<!--#_ if(LogoSrc){ _#-->
<img src="_#= $htmlEncode(LogoSrc) =#_" />
<!--#_ } _#-->
<!--#_ if(LogoSrc.isEmpty){ _#-->
<p style="font-size: 13pt; font-family: 'Malgun Gothic', Arial, sans-serif; color: #000000; font-weight: 700; text-transform: uppercase;">_#= Title =#_</p>
<!--#_ } _#-->