{"id":750,"date":"2022-08-30T15:06:33","date_gmt":"2022-08-30T15:06:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/conditionally-displaying-ejs-data-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:06:33","modified_gmt":"2022-08-30T15:06:33","slug":"conditionally-displaying-ejs-data-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/conditionally-displaying-ejs-data-collection-of-common-programming-errors\/","title":{"rendered":"Conditionally Displaying EJS data-Collection of common programming errors"},"content":{"rendered":"<p>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<\/p>\n<pre><code>   <\/code><\/pre>\n<ul data-role=\"listview\" data-theme=\"a\">PROBLEM HERE&#8212;-&gt;<\/ul>\n<pre>\n<\/pre>\n<p><code>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?<\/code><\/p>\n<ol>\n<li>\n<p><code>Like <code>for<\/code>, you can also use <code>if<\/code> in EJS:<\/code><\/p>\n<pre><code>\n   \n\n<\/code><\/pre>\n<p>Or, if you just want to prevent <code>undefined<\/code> being shown when a property isn&#8217;t defined, you can use this:<\/p>\n<pre><code> \n<\/code><\/pre>\n<p>(be aware that this would fail for properties containing the number <code>0<\/code> or a boolean <code>false<\/code>)<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:38:02. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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&#8212;-&gt; 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. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-750","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=750"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/750\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}