machty / emblem.js

Emblem.js - Ember-friendly, indented syntax alternative for Handlebars.js
http://emblemjs.com
MIT License
1.04k stars 81 forks source link

Inverse yielding requires unexpected indentation #266

Closed SaladFork closed 8 years ago

SaladFork commented 8 years ago

NOTE: The examples in this comment are not actually correct as I had not properly simplified the problem. Please see my correction in a follow-up comment.


/ only way that works
some-component-with-inverse-yield
  | foo
  else
  | bar

/ doesn't work (this is what I'd expect to work)
some-component-with-inverse-yield
  | foo
else
  | bar

/ doesn't work
some-component-with-inverse-yield
  | foo
  else
    | bar

The ones that don't work result in an error:

Uncaught Error: Assertion Failed: A helper named 'else' could not be found

Equivalent handlebars:

{{#some-component-with-inverse-yield}}
  foo
{{else}}
  bar
{{/some-component-with-inverse-yield}}
thec0keman commented 8 years ago

@SaladFork can you confirm if this is still an issue?

I am seeing the following working:

some-component-with-inverse-yield
  |foo
else
  |bar

=> 
{{#some-component-with-inverse-yield}}
  foo
{{else}}
  bar
{{/some-component-with-inverse-yield}}
SaladFork commented 8 years ago

Ah, my mistake. As posted you are correct. I've done some more research and the fail condition is when you switch to multi-line declarations with square brackets:

/ works
some-component-with-inverse-yield value=true
  | foo
else
  | bar

/ doesn't work
some-component-with-inverse-yield [
  value=true ]
  | foo
else
  | bar

/ works
some-component-with-inverse-yield [
  value=true ]
  | foo
  else
  | bar
thec0keman commented 8 years ago

#274 should resolve this