twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

defaults.def (1285B)


      1 {{## def.assignDefault:
      2   {{? it.compositeRule }}
      3     {{
      4       if (it.opts.strictDefaults) {
      5         var $defaultMsg = 'default is ignored for: ' + $passData;
      6         if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
      7         else throw new Error($defaultMsg);
      8       }
      9     }}
     10   {{??}}
     11     if ({{=$passData}} === undefined
     12       {{? it.opts.useDefaults == 'empty' }}
     13         || {{=$passData}} === null
     14         || {{=$passData}} === ''
     15       {{?}}
     16     )
     17       {{=$passData}} = {{? it.opts.useDefaults == 'shared' }}
     18                          {{= it.useDefault($sch.default) }}
     19                        {{??}}
     20                          {{= JSON.stringify($sch.default) }}
     21                        {{?}};
     22   {{?}}
     23 #}}
     24 
     25 
     26 {{## def.defaultProperties:
     27   {{
     28     var $schema = it.schema.properties
     29       , $schemaKeys = Object.keys($schema); }}
     30   {{~ $schemaKeys:$propertyKey }}
     31     {{ var $sch = $schema[$propertyKey]; }}
     32     {{? $sch.default !== undefined }}
     33       {{ var $passData = $data + it.util.getProperty($propertyKey); }}
     34       {{# def.assignDefault }}
     35     {{?}}
     36   {{~}}
     37 #}}
     38 
     39 
     40 {{## def.defaultItems:
     41   {{~ it.schema.items:$sch:$i }}
     42     {{? $sch.default !== undefined }}
     43       {{ var $passData = $data + '[' + $i + ']'; }}
     44       {{# def.assignDefault }}
     45     {{?}}
     46   {{~}}
     47 #}}