twitst4tz

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

if.jst (1640B)


      1 {{# def.definitions }}
      2 {{# def.errors }}
      3 {{# def.setupKeyword }}
      4 {{# def.setupNextLevel }}
      5 
      6 
      7 {{## def.validateIfClause:_clause:
      8   {{
      9     $it.schema = it.schema['_clause'];
     10     $it.schemaPath = it.schemaPath + '._clause';
     11     $it.errSchemaPath = it.errSchemaPath + '/_clause';
     12   }}
     13   {{# def.insertSubschemaCode }}
     14   {{=$valid}} = {{=$nextValid}};
     15   {{? $thenPresent && $elsePresent }}
     16     {{ $ifClause = 'ifClause' + $lvl; }}
     17     var {{=$ifClause}} = '_clause';
     18   {{??}}
     19     {{ $ifClause = '\'_clause\''; }}
     20   {{?}}
     21 #}}
     22 
     23 {{
     24   var $thenSch = it.schema['then']
     25     , $elseSch = it.schema['else']
     26     , $thenPresent = $thenSch !== undefined && {{# def.nonEmptySchema:$thenSch }}
     27     , $elsePresent = $elseSch !== undefined && {{# def.nonEmptySchema:$elseSch }}
     28     , $currentBaseId = $it.baseId;
     29 }}
     30 
     31 {{? $thenPresent || $elsePresent }}
     32   {{
     33     var $ifClause;
     34     $it.createErrors = false;
     35     $it.schema = $schema;
     36     $it.schemaPath = $schemaPath;
     37     $it.errSchemaPath = $errSchemaPath;
     38   }}
     39   var {{=$errs}} = errors;
     40   var {{=$valid}} = true;
     41 
     42   {{# def.setCompositeRule }}
     43   {{# def.insertSubschemaCode }}
     44   {{ $it.createErrors = true; }}
     45   {{# def.resetErrors }}
     46   {{# def.resetCompositeRule }}
     47 
     48   {{? $thenPresent }}
     49     if ({{=$nextValid}}) {
     50       {{# def.validateIfClause:then }}
     51     }
     52     {{? $elsePresent }}
     53       else {
     54     {{?}}
     55   {{??}}
     56     if (!{{=$nextValid}}) {
     57   {{?}}
     58 
     59   {{? $elsePresent }}
     60       {{# def.validateIfClause:else }}
     61     }
     62   {{?}}
     63 
     64   if (!{{=$valid}}) {
     65     {{# def.extraError:'if' }}
     66   } 
     67   {{? $breakOnError }} else { {{?}}
     68 
     69   {{# def.cleanUp }}
     70 {{??}}
     71   {{? $breakOnError }}
     72     if (true) {
     73   {{?}}
     74 {{?}}
     75