Forum: Ruby green_shoes initial woes

7b3c42ad9cb173f34a9358c8ee4afc2c?d=identicon&s=25 Baban By (baban)
on 2013-05-27 22:38
Hi, just started with green_shoes this morning by installing the gem.
Unfortunately, my first simple program fell over with this error.

I have an array of strings that I fill in as follows:

<some loop code> do|field|
    items.push("#{field[:name]}")
end

(I can print the items object and see all the strings I stuffed)

Then I created a Shoes app:

Shoes.app do
  items.each do |i|
    para i
  end
end

This produces:
<path>/green_shoes-1.1.374/lib/shoes/helper_methods.rb:127:in
`parse_markup': Error on line 1: Character ' ' is not valid at the start
of an entity name; the & character begins an entity; if this ampersand
isn't supposed to be an entity, escape it as &amp; (GLib::Error)

I also tried:

str = items.map { |i| i.to_s }.join("\n")

and

Shoes.app do
    para str
end

and this produces the same error as above.

Any help will be much appreciated!
689dae2a2a14404ed27048633f472147?d=identicon&s=25 ashbb shoeser (satoshi_a)
on 2013-05-28 13:24
(Received via mailing list)
Hi Baban,

Could you show us the output of the following code which use `p` instead
of
`para`? I want to know the strings you pushed into `items`.

Shoes.app do
  items.each do |i|
    p i
  end
end

Regards,
ashbb
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-05-28 13:28
Something in your names isn't escaped properly. Looks like you might
have a name containing '&'.
What's in the variable 'field'?
7b3c42ad9cb173f34a9358c8ee4afc2c?d=identicon&s=25 Baban By (baban)
on 2013-05-28 15:28
Joel Pearson wrote in post #1110369:
> Something in your names isn't escaped properly. Looks like you might
> have a name containing '&'.
> What's in the variable 'field'?

Thanks ashbb and Joel! There was indeed an '&' in one of the strings.
However, I can see the same issue with:

str = "hello \\& bye"

Shoes.app {para str}
7b3c42ad9cb173f34a9358c8ee4afc2c?d=identicon&s=25 Baban By (baban)
on 2013-05-28 15:34
Baban By wrote in post #1110376:
> Joel Pearson wrote in post #1110369:
>> Something in your names isn't escaped properly. Looks like you might
>> have a name containing '&'.
>> What's in the variable 'field'?
>
> Thanks ashbb and Joel! There was indeed an '&' in one of the strings.
> However, I can see the same issue with:
>
> str = "hello \\& bye"
>
> Shoes.app {para str}

Scratch that. I did not read the message carefully. This works just
fine:

str = 'hello &amp; bye'
Shoes.app {para str}

Thanks for the prompt help!
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-05-28 16:56
Using CGI.escapeHTML on each string would probably be a better long-term
solution.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.