express-handlebars icon indicating copy to clipboard operation
express-handlebars copied to clipboard

Else If Statement Failure

Open phantom-factotum opened this issue 6 years ago • 1 comments

I don't know if my code is flawed (I'm a rookie enthusiast), but I cannot get the else if statements to work for my handlebars engine. I saw that its available for handlebars 3.0+ and I tweaked and played with the code with no desirable results. According to the Handlebars site I using (Im pretty sure it was the official site) the code should be like this

{{#if noEmployees}}
	<p>Add or simulate employees for more features</p>
{{#if else failedSearch}}
	<p>The parameters entered did not match any employee data</p>
{{#if else successSearch}}
	<h1 class= 'text-center'>{{searchNum}} results for "{{searchParams}}"</h1>
{{else}}
	<p>You looking through all {{searchNum}} of your employees! Sure you don't want to filter?</p>
{{/if}}

I tweaked the code, adding closing if and else tags ({{/if}},{{else}}), tried using {{/else if}} and dozens of other foolish things to make things work but I was stumped. I thought, maybe express-handlebars doesn't have else if capacity and I wrote my else if statements as the following:

{{#if noEmployees}}
		<p>Add or simulate employees for more features</p>
{{/if}}
{{#else}}
	{{#if failedSearch}}
		<p>The parameters entered did not match any employee data</p>
	{{/if}}
	{{#else}}
		{{#if successSearch}}
			<h1 class= 'text-center'>{{searchNum}} results for "{{searchParams}}"</h1>
		{{/if}}
		{{#else}}
			<p>You looking through all {{searchNum}} of your employees! Sure you don't want to filter?</p>
		{{/else}}
	{{/else}}
{{/else}}

While this compiles it doesn't do anything if the first if statement is falsed. I tried my usual technique of doing random, sometimes foolish things and got no where and I am utterly confused. I do not know if its me lacking skill/knowledge or a flaw in this library. Help me please

phantom-factotum avatar Dec 07 '18 02:12 phantom-factotum

this might help: https://handlebarsjs.com/builtin_helpers.html

{{#if noEmployees}}
		<p>Add or simulate employees for more features</p>
{{else}}
	{{#if failedSearch}}
		<p>The parameters entered did not match any employee data</p>
	{{else}}
		{{#if successSearch}}
			<h1 class= 'text-center'>{{searchNum}} results for "{{searchParams}}"</h1>
		{{else}}
			<p>You looking through all {{searchNum}} of your employees! Sure you don't want to filter?</p>
		{{/if}}
	{{/if}}
{{/if}}

UziTech avatar Jan 09 '19 04:01 UziTech