outmoded / lout

API documentation generator
Other
276 stars 49 forks source link

default value not displayed if false #168

Closed firsttris closed 7 years ago

firsttris commented 7 years ago

hello, if a default value is false it will not be displayed. Is this the desired behavior?

Example:

'deleted': Joi.boolean().default(false)

Row in Template

https://github.com/hapijs/lout/blob/master/templates/type.html#L133

Possible Solution

{{#isDefined this.flags.default}}
     <dt class="default-value">Default value</dt>
     <dd class="default-value">{{json this.flags.default}}</dd>
{{/isDefined}}

// isDefined.js
module.exports = function (a, opts) {
  if (a === undefined || a === null) {
    return opts.inverse(this);
  }

  return opts.fn(this);
};

best regards Tristan

Marsup commented 7 years ago

Close but I chose to re-use a helper that was already there, thanks for the bug report and analysis !