Conditionally Displaying EJS data-Collection of common programming errors

I am trying to reuse a a view in EJS. It just creates a list of the results of a database query. My code is

   
    PROBLEM HERE—->

I would only like to show each records[i].Name and records[i].TOJ if they are defined or if the view is called from a certain route or whatever is easier. I have tried inserting a function to filter, but it just got ignored. How can i do this?

  1. Like for, you can also use if in EJS:

    
       
    
    

    Or, if you just want to prevent undefined being shown when a property isn’t defined, you can use this:

     
    

    (be aware that this would fail for properties containing the number 0 or a boolean false)

Originally posted 2013-11-09 22:38:02.