defaults.def 978 B

12345678910111213141516171819202122232425262728293031323334353637
  1. {{## def.assignDefault:
  2. if ({{=$passData}} === undefined
  3. {{? it.opts.useDefaults == 'empty' }}
  4. || {{=$passData}} === null
  5. || {{=$passData}} === ''
  6. {{?}}
  7. )
  8. {{=$passData}} = {{? it.opts.useDefaults == 'shared' }}
  9. {{= it.useDefault($sch.default) }}
  10. {{??}}
  11. {{= JSON.stringify($sch.default) }}
  12. {{?}};
  13. #}}
  14. {{## def.defaultProperties:
  15. {{
  16. var $schema = it.schema.properties
  17. , $schemaKeys = Object.keys($schema); }}
  18. {{~ $schemaKeys:$propertyKey }}
  19. {{ var $sch = $schema[$propertyKey]; }}
  20. {{? $sch.default !== undefined }}
  21. {{ var $passData = $data + it.util.getProperty($propertyKey); }}
  22. {{# def.assignDefault }}
  23. {{?}}
  24. {{~}}
  25. #}}
  26. {{## def.defaultItems:
  27. {{~ it.schema.items:$sch:$i }}
  28. {{? $sch.default !== undefined }}
  29. {{ var $passData = $data + '[' + $i + ']'; }}
  30. {{# def.assignDefault }}
  31. {{?}}
  32. {{~}}
  33. #}}