Reputation: 59
I'm coding a custom SharePoint Item_XX.html template which is feeding in data from my SharePoint custom list. I'm not sure how to 'break up' script though. How do I use an if-else statement where the output displays html?
You'll see I'm trying to say: If there is LogoSrc data, add the data to the image src. Otherwise display text (dtaa from the title field)
<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>
Upvotes: 0
Views: 196
Reputation: 59
SharePoint Item_XX.html files requires a specific script syntax. The solution would be:
<!--#_ 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>
<!--#_ } _#-->
Upvotes: 1