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

multi line coffeescipt in <% ... %> #41

Open
sircambridge opened this issue Mar 9, 2012 · 21 comments
Open

multi line coffeescipt in <% ... %> #41

sircambridge opened this issue Mar 9, 2012 · 21 comments

Comments

@sircambridge
Copy link

being able to have multiple line coffeescript execute within <% %> would be awesome.

in erb and ejs, you can say

<%
  def something(arg)
    ...
  end
%>

or

<%
 function(){
 ...
}
%>

is there a workaround / somewhere i can hack this in ?

@pehrlich
Copy link

I've wondered this as well. Or is it intentionally so, to prevent complex templating?

@ckihneman
Copy link

+1. This would be a great feature, maybe it needs a special syntax of its own to trigger on so it knows indentation now matters...

<%*
    someVar = @something
    if someVar
      # do other stuff
*%>

Or something like that. I switched to eco from jQote2 and this is the only thing really giving me a large amount of frustration. Logic-less templates just are not in my cards for the project im on...

I made it work by wrapping everything in a <% someVar = @something %> for every line (and added : for any ifs/whatnot) - which is for sure not optimal when a couple lines of coffeescript do a lot better.

Thanks.

@balupton
Copy link

+1, I've wanted to do:

<%-
    data = @require('util').inspect @documentModel.getAttributes()
    delete data.fullPath
    delete data.outPath
    data
%>

but can't figure out how

@pehrlich
Copy link

As I use Eco, I'm getting a little bit torn on this, actually. I think it would encourage cluttery awful views, which would be bad, and my templates have actually been improved through this limitation. But at the same time, hashes would seem more acceptable to have multiline. They're essentially declarative, and can be quire useful.

For example, look at this formbuilder becomes frustrating to work with on a single line, (the alternative, assigning each argument to a variable, is also frustrating).

    <%- @select 'param_name', ['New York', 'San Francisco'], {class: 'my_class input-small', data: {toggle: 'dropdown'}, title: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'} %>

hmm. thoughts?

@asgeo1
Copy link

asgeo1 commented May 4, 2012

+1, this is really needed.

I try to keep my code to 80 chars wide, so I need to be able to start a new line. It looks awful when every line begins with <% for no reason.

@AlexMost
Copy link

AlexMost commented Jul 3, 2012

+1 ... really need

@manenko
Copy link

manenko commented Jul 8, 2012

+1

@rprieto
Copy link

rprieto commented Jul 11, 2012

Definitely interested in this too, especially for "declarative" sections, like hashes, arrays...

@robhawkes
Copy link

+1

Trying to do heredoc statements for multi-line variables but finding it impossible with eco.

@nfour
Copy link

nfour commented Oct 18, 2012

Seems a developers has gone awol again. First coffeekup, now this?

I'd be happy to code in the changes myself though it's a little awkward putting time into a issue-accumulating repository. Where you at stephenson? :)

@aseemk
Copy link

aseemk commented Dec 4, 2012

(For reference, issues #13 and #15. Not sure if anything has changed.)

@aseemk
Copy link

aseemk commented Dec 4, 2012

But FWIW, @malgorithms's Toffee is an excellent alternative to Eco and supports multi-line blocks:

https://github.com/malgorithms/toffee

@malgorithms
Copy link

If someone wants to try to add this to Eco, I'd be happy to share the experiences I had making it work with Toffee. It was kind of a fun challenge. And difficult due to indentation considerations. You can find my contact info on my github page.

I think it'll be pretty deep down in the parser.

Thanks for the shoutout to Toffee, @aseemk . Not too many people know about it...yet :-)

@tusharr
Copy link

tusharr commented Feb 7, 2013

+1
This is one thing that I can't easily get over.

@nfour
Copy link

nfour commented Feb 21, 2013

For anyone still wishing for this, ECT http://ectjs.com/ is still rather actively developed, and open to feature suggestions. Wrote a ST2/TM .tmLanguage for it too. Has multiline capabilities, and is much much faster than ECO.

@gbouthenot
Copy link

thank for these 2 alternatives :
http://ectjs.com/
https://github.com/malgorithms/toffee

Unfortunately, none of these solutions are (yet) supported by Ruby on Rails.

@jifka
Copy link

jifka commented Jul 14, 2013

++1

@mbhnyc
Copy link

mbhnyc commented Jul 15, 2013

what is needed to get some of the alternatives up and running? dived a little into ECO's gemfile and won't pretend to completely understand. ;)

@cweezy
Copy link

cweezy commented Oct 28, 2013

+1.There's cases where I just want a few lines for an if/else or something.

@caiogondim
Copy link

+1

@sapegin
Copy link

sapegin commented Jan 23, 2015

👍

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