Note that there are some explanatory texts on larger screens.

plurals
  1. POchecking whether a field exists in Jade
    primarykey
    data
    text
    <p>Consider this snippet of Jade:</p> <pre><code>if(#{episode[question.name][field]}) #{episode[question.name][field]} </code></pre> <p>I want to check if the value of <code>episode[question.name][field]</code> exists. If it does, output the value on the next line.</p> <blockquote> <p>500 SyntaxError: Unexpected token ILLEGAL</p> </blockquote> <p>Here is the current source and more information.</p> <pre><code>h1= title </code></pre> <p>p Welcome to #{title}</p> <pre><code>ol#questions each question in questions li ul#question li: h3 (#{question.name}) #{question.description} - if(question.options) ul#options for option, i in question.options if(typeof(option) === "object") li: h3 #{i} ul#option each soption in option li input(type='checkbox', name='episode[#{question.name}][#{soption}]', checked='#{episode[question.name][soption]}') // label #{soption} else li input(type='checkbox', name='episode[#{question.name}][#{option}]', checked='#{episode[question.name][option]}') // label #{option} if(typeof(question.fields) !== 'undefined') for field, i in question.fields if(field === "Date") p.date if(#{episode[question.name][field]} !== "undefined") #{episode[question.name][field]} else p input(name='episode[#{question.name}][#{field}]', class='', value="#{episode[question.name][field]}") </code></pre> <p>and here is the data object passed in</p> <pre><code> episode = { "form": { "formid": "4efd9c4cae999dcf0a12c461", "name": "ROC" }, "patientid": ObjectId("4ef6835a7a5869082a80bc95"), "certperiodid": ObjectId("4f020ff0850b21bc2b000001"), "M0080": { "2-PT": "on", "3-SLP\/ST": "on", "4-OT": "on" }, "M0090": { "Date": "2012-01-02" }, "M0100": { "1 - Start of care--further visits planned": "on", "3 - Resumption of care (after inpatient stay)": "on" }, "M00104": { "Date": "2012-05-02" }, "_id": ObjectId("4f071a0424ddf0dd66000003") } </code></pre> <p>How can this be fixed and written correctly?</p> <p>so for example if one of the date fields are empty (not filled in), in order to prevent an error , i need to check if its not empty, before outputting the value.</p> <p>thanks again in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload