Erb question --urgent help needed?

i don’t know how to explain my problem
here i am showing it by an example

<%
string=“Hello Ruby ,How are you” # any String object
width=28 # because width of the below erb tag
is 28
%>
<%=p “%#{-width}s”%string %>

the answer is

=>"Hello Ruby ,How are you "

in above erb tag ("<%=p “%#{-width}s”%string%>") length is 28
so i assigned width=28

here is my question
how to define the width at dynamically for any type of erb tags ?

On Fri, Jun 6, 2008 at 7:20 AM, Pokkai D. [email protected]
wrote:

the answer is

=>"Hello Ruby ,How are you "

in above erb tag (“<%=p “%#{-width}s”%string%>”) length is 28
so i assigned width=28

here is my question
how to define the width at dynamically for any type of erb tags ?

Can you tell what do you want to do? Why do you need to know the
length of the tag?
Do you want to pad the text with spaces?

What’s wrong with the following?

<%
string=“Hello Ruby ,How are you” # any String object
%>
<%= string %>

Jano S. wrote:

On Fri, Jun 6, 2008 at 7:20 AM, Pokkai D. [email protected]
wrote:

Can you tell what do you want to do? Why do you need to know the
length of the tag?
Do you want to pad the text with spaces?

What’s wrong with the following?

<%
string=“Hello Ruby ,How are you” # any String object
%>
<%= string %>

in my ROR project i need to show some details with PRINT format
so i need like that

Jano S. wrote:

On Fri, Jun 6, 2008 at 7:20 AM, Pokkai D. [email protected]
wrote:

Can you tell what do you want to do? Why do you need to know the
length of the tag?
Do you want to pad the text with spaces?

What’s wrong with the following?

<%
string=“Hello Ruby ,How are you” # any String object
%>
<%= string %>

actually there is a empty paper

in that paper some datas want to print for some corresponding position
(see below…like name,phone. etc…)

#empty paper

| |
| name: phone: |
| |
| post: comment: |
| |

address:

#paper after print

| |
| name:mokkai phone: 919234244 |
| |
| post:somthing comment: nothing |
| |

address:full address detail here…

so i want to create print details in .rhtml format

On Fri, Jun 6, 2008 at 4:33 PM, Jano S. [email protected]
wrote:

One more suggestion: with PdfWriter, you can programmatically produce
PDFs
with proportional fonts, placing each text on its precise coordinates.
You can achieve nicer output, if the required processing is feasible.

J.

On Fri, Jun 6, 2008 at 10:55 AM, Pokkai D. [email protected]
wrote:

| post: comment: |
| |

address:full address detail here…

so i want to create print details in .rhtml format

I can’t help you with a general solution, I guess the way you startes
is the way to go.
Though:

  1. you don’t need p there - instead of <%=p just leave there <%=
  2. create a helper function to pad the string to desired width

def pad(lenght, data)
data.to_s.just(length)
end

then you can do:

<%= pad 28, name %><%= pad 15, phone_number %> etc.

I quite can’t imagine what you mean by “define the width at
dynamically for any type of erb tags”.
Don’t worry though, the problem is most probably somewhere between my
keyboard and my chair :wink:

J.