Hi all,
Hope you are well.
I'm having a go with the HTML Templates but I'm stuck on using the IF statement. It confused me as some websites point out that HTML doesn't support that but I saw few examples of email confirmations that have it, even though they just apply in case the field is null or not.
I'm looking for a way to show a specific text if the seats booked belong to the standing area, so I tried with something like this:
@foreach (var subLineItem in product.Performance.LineItem.SubLineItems) {
if(subLineItem.Seat.Row = 'U'){
<p>Standing</p> }
else {
var seatRow = string.IsNullOrEmpty(subLineItem.Seat.Number) ? "TBD" : subLineItem.Seat.Row + " " + subLineItem.Seat.Number; @seatRow<br/>
}
And of course, it doesn't work, and I tried changing few bits but can't find the solution.
does anyone has some examples that he's willing to share, please?
Many Thanks,Sergio
Hi Sergio,
One important thing to note is that HTML indeed does not have IF statements. Tessitura HTML Templates are (ironically) not HTML. They are a syntax called Razor that allows for the generation of dynamic HTML by using C#. I wrote a wiki page describing some of the details of this setup.
The C# environment has a Model object available, which has properties described in the documentation for each template type. You seem to be on the right track, although just looking at your code I see the use of the assignment = when you probably meant an equality check ==. Generally I can figure out issues with my templates by making incremental changes from a known working state in a tight testing loop so I know exactly what part of my code isn't working as I expect it to.
I would also invite you to join our slack channel dedicated to HTML templates to see what other people are doing: https://tessituranetwork.com/devs
Hi Nick,
Thank you for the details! I'm glad there's a chance to use IF then!the code I wrote in the topic was just an example, I tried with == but didn't work, I might doing something else wrong! I will give it another go!
Also thank you for the article and the invitation, I have accepted it now!
Sergio