Every line of 'react inline if' 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.
141 export function inlineIf(_vm: VM, { positional }: Arguments) { 142 assert( 143 'The inline form of the `if` helper expects two or three arguments, e.g. ' + 144 '`{{if trialExpired "Expired" expiryDate}}`.', 145 positional.length === 3 || positional.length === 2 146 ); 147 return ConditionalHelperReference.create(positional.at(0), positional.at(1), positional.at(2)); 148 }
7 export default function If(_ref) { 8 var condition = _ref.condition, 9 children = _ref.children; 10 11 return condition ? children : null; 12 }
3 export default function RenderIf({ isTrue, children }) { 4 if (isTrue) { 5 return children; 6 } 7 return null; 8 }
12 render() { 13 const value = this.getValue(); 14 const { cond, children } = this.props; 15 const parent = this.getParent(); 16 if (typeof cond !== 'function' || !children) { 17 return null; 18 } 19 20 const canShow = cond(value); 21 if (!canShow) { 22 return null; 23 } 24 25 return Children.only(parent.processChildren(children)); 26 }