Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Make switch statements work #38

Open
thiloplanz opened this issue Jan 28, 2012 · 3 comments
Open

Make switch statements work #38

thiloplanz opened this issue Jan 28, 2012 · 3 comments

Comments

@thiloplanz
Copy link

It seems that you cannot have a Coffeescript switch statement in an eco template:

http://stackoverflow.com/questions/8920981/can-i-use-a-coffeescript-switch-block-in-eco

Or if you can, it is not obvious how.

@bigeasy
Copy link

bigeasy commented Jan 28, 2012

I'm able to get a switch statement out of Eco when I remove when from the dedent regular expression in scanner.coffee, then create a template that expresses a switch statement on a single line, with no text between the switch and when statements.

There would have to be logic added to the scanner or preprocessors that turns off text gathering while in a switch. The first when would have to not dedent.

Picking at this. It's not pretty. Because when is in the dedent regex, I imagine that supporting switch is desired, but not there yet. I can implement it if is desired, or create an implementation and @sstephenson can decide if it is worth adding the clutter to scanner.

An example implementation can be found in this branch.

https://github.com/bigeasy/eco/commit/337c9e12a8d0c2b312f912875b6b8f28033cebbf

https://github.com/bigeasy/eco/blob/switch/switch.coffee

@jifka
Copy link

jifka commented Jul 7, 2013

Any progress on this? Is no one else interested in switch statements?

@duhast
Copy link

duhast commented May 22, 2014

I am. Having switch available in eco would be nice!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants