10 examples of 'ejs if else' in JavaScript

Every line of 'ejs if else' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
119function genIf (el: any): string {
120 el.ifProcessed = true // avoid recursion
121 return genIfConditions(el.ifConditions.slice())
122}
257function genIf (el) {
258 el.ifProcessed = true;
259 if (!el.ifConditions.length) {
260 return '_e()';
261 }
262 return `(${el.ifConditions[0].exp})?${genElement(el.ifConditions[0].block)}: _e()`
263}
56else(e) {
57 this.els = e;
58 return this;
59}
934function JSIfElse(cond, truebody, falsebody) {
935 this.cond = cond;
936 this.truebody = truebody;
937 this.falsebody = falsebody;
938}
22function IF(condition, ifContents, elseContents){
23 this.condition = condition;
24 this.ifContents = ifContents;
25 this.elseContents = elseContents;
26}
133if(expression) {
134 return {
135 $type: "if",
136 condition: this._getParamNames(arguments[0])[0],
137 expression: expression,
138 children: arguments[1]
139 }
140}
104function If(condExpr, thenExpr, elseExpr) {
105 this.tag = "If";
106 this.condExpr = condExpr;
107 this.thenExpr = thenExpr;
108 this.elseExpr = elseExpr;
109}
9export function compileIf(compiler: Compiler, node: typescript.IfStatement): binaryen.Statement {
10 const op = compiler.module;
11
12 return op.if(
13 compiler.compileExpression(node.expression, reflection.intType, reflection.intType, true),
14 compiler.compileStatement(node.thenStatement),
15 node.elseStatement ? compiler.compileStatement(node.elseStatement) : undefined
16 );
17}
73function if_expr(condition, then, _else) {
74 return { 'if': condition, then: then, 'else': _else };
75}
103function genIfConditions (conditions) {
104 if (!conditions.length) {
105 return '_e()'
106 }
107
108 const condition = conditions.shift() // 因为我们并没有去真正删除 el.ifConditions 队列的元素,所以需要有el.ifProcessed = true来结束递归
109 if (condition.exp) {
110 return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions)}`
111 } else {
112 return `${genTernaryExp(condition.block)}`
113 }
114
115 function genTernaryExp (el) {
116 return genElement(el)
117 }
118}

Related snippets