Skip to content

Why on earth would you write something without as as basic a thing as a conditional like if/then/else??? #2010

@evilgeniuscreative

Description

@evilgeniuscreative

Before filing issues, please check the following points first:

This will probably help you to get a solution faster.
For bugs, it would be great to have a PR with a failing test-case.

SERIOUSLY??

<section id="presidents">
  {{#each data}}
<figure class="president">
  {{#if  this.name = "John Adams"}}
      <img src="https://commons.wikimedia.org/wiki/File:John_Adams_A18236.jpg" alt={{this.name}} />
      <caption>{{this.name}}</caption>
  {{else}}
    <img src={{this.photo}} alt={{this.name}} />
    <caption>{{this.name}}</caption>
  {{/if}}

  </figure>
{{/each}}
</section>

Error: /Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/views/presidents.hbs: #if requires exactly one argument
at Object. (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/helpers/if.js:17:13)
at Object.wrapper (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/internal/wrapHelper.js:15:19)
at eval (eval at createFunctionContext (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:262:23), :11:47)
at prog (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/runtime.js:268:12)
at execIteration (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/helpers/each.js:51:19)
at Object. (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/helpers/each.js:61:13)
at Object.wrapper (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/internal/wrapHelper.js:15:19)
at Object.eval [as main] (eval at createFunctionContext (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:262:23), :11:49)
at main (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/runtime.js:208:32)
at ret (/Users/studio/GeneralAssembly/Mod2_React_Express/sandbox/SomeSite/node_modules/hbs/node_modules/handlebars/dist/cjs/handlebars/runtime.js:212:12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions