erb with -%> from command line?

I can't seem to google this one effectively: Can someone tell me how to invoke erb in such a way that the -%> sequence kills newlines as it does in rails? I've tried everything I can think of, effectively

  for i in 0 1 2 '-' do     erb -T $i template.rhtml   done

but I can't get it to work -- erb still sees the - as part of the text. Does Rails invoke something else? I can't see any refs to what that might be in AWDWR. I'm trying to create something outside rails, so can't just put this where a template would live.

Thank you Hugh

I don't know the answer to this problem but i may have a workaround. If you're just using it to generate html have you considered Haml or Markaby instead of erb? They might be easier to use and suffer newline problems differently.

On the other hand, if you're using erb to parse text (eg: a yaml file) then this probably wouldn't help much.

If nothing my hope is that you didn't know about Haml and fall instantly in love with it :slight_smile:

-Chuck Vose

I don't know the answer to this problem but i may have a workaround. If you're just using it to generate html have you considered Haml or Markaby instead of erb? They might be easier to use and suffer newline problems differently.

OK, I've looked at that now.
1) I'm trying to do this outside rails, so I get static data for    my fixtures generated just the once, for now. Maybe later I'll    regenerate it each time to cook up stress tests, but for now...    So this being a plugin is not actually much help unless it is    accessible outside Rails. I don't see much about that from    the tutorial.

2) Haml seems geared to tackle the verbosity of HTML, abut I don't    immediately see from the tutorial how it helps with Ruby interpolation.

3) It's just one more wafer thin syntax to learn. :slight_smile:

On the other hand, if you're using erb to parse text (eg: a yaml file) then this probably wouldn't help much.

I'm generating YAML programmatically.

If nothing my hope is that you didn't know about Haml and fall instantly in love with it :slight_smile:

People are going to have a job spreading this meme to their parents with things like this in the tutorial:

"Yrg'f gnxr gung shpxre naq znxr vg n Unzy Unvxh!!!!!".rot13

Programs that semi-automatically decide on site blocking may get interesting results, as well...

-Chuck Vose

Thank you for your answer, all the same. I've not closed my mind to this possibility, and it may well have other features I need, even for other things.

        Thank you         Hugh

I can't seem to google this one effectively: Can someone tell me how to invoke erb in such a way that the -%> sequence kills newlines as it does in rails? I've tried everything I can think of, effectively

  for i in 0 1 2 '-' do     erb -T $i template.rhtml   done

but I can't get it to work -- erb still sees the - as part of the text. Does Rails invoke something else? I can't see any refs to what that might be in AWDWR. I'm trying to create something outside rails, so can't just put this where a template would live.

when I invoke `erb -T "-" tom.rhtml` I get <html> </html>

tom.rhtml: <html> <% @tom = 3 -%> </html>

Doesn't even work with the other trim settings. Can you drop us the rhtml you're using? Not sure why it seems to work on mine but not on yours.

[...]

> as it does in rails? I've tried everything I can think of, effectively > > for i in 0 1 2 '-' do > erb -T $i template.rhtml > done

        [...]

when I invoke `erb -T "-" tom.rhtml` I get <html> </html>

tom.rhtml: <html> <% @tom = 3 -%> </html>

Doesn't even work with the other trim settings. Can you drop us the rhtml you're using? Not sure why it seems to work on mine but not on yours.

Ah. I see what is happening now. If I reduce my example to slightly bigger than yours I get this (Cygwin):

hgs@Q2P14HGS ~/nonsense-0.6 $ erb -T "-" tom.rhtml <html> <pre>0 1 2 3 4 </pre> </html>

hgs@Q2P14HGS ~/nonsense-0.6 $ cat tom.rhtml <html> <pre><%= s = ""; 5.times{|k| s += k.to_s + " "}; s -%></pre> </html>

hgs@Q2P14HGS ~/nonsense-0.6 $ erb -T "-" test_employees.rhtml test_employees.rhtml:13:in ``': Interrupt         from test_employees.rhtml:13:in `nonsense'         from test_employees.rhtml:128         from test_employees.rhtml:123:in `upto'         from test_employees.rhtml:123

hgs@Q2P14HGS ~/nonsense-0.6 $

So If I don't use -T "-" or -T '-' I get the errors I had before, but when this didn't do anything I thought it was treating the - as stdin and it was sitting there, waiting. I've disproved that now, so I've thereby proved something is taking forever in my code, which is being interpreted correctly. I'll spare you the details of my buggy code, and thank you for helping me prove that assumption (of stdin) was wrong.

        Thank you,         Hugh