[Nitro] [PATCH/RFC] Make element ids unique

George Moschovitis george.moschovitis at gmail.com
Tue Nov 27 03:22:51 EST 2007


I have done something similar in the past, but due to  some problems I
removed it.
The bad thing is that I do not remember the actual problems any more :(

In any case, thanks for the patch. I will have a  look at it and apply it if
it doesnt break my tests/apps.

thanks,
-g.

On Nov 27, 2007 7:42 AM, Arne Brasseur <arne at arnebrasseur.net> wrote:

> Hi devs,
>
> The template compiler for elements automatically sets the instance
> variable @id based on either an explicit id attribute in the html or the
> name of the class.
>
> e.g.
> class LoginBox
> def render
> %~<div id="@id">...</div>~
> end
> end
>
> <LoginBox />
> <LoginBox />
> <LoginBox />
> <LoginBox id="my_id"/>
> <LoginBox id="my_id"/>
>
> This will result in
> <div id="login_box">...</div>
> <div id="login_box">...</div>
> <div id="login_box">...</div>
> <div id="my_id">...</div>
> <div id="my_id">...</div>
>
> Also, when nesting elements the children are kept in a Dictionary and
> the @id is used as lookup key, so in the above example only the third
> and the fifth box would be visible for the parent.
>
> The attached patch changes the element compiler to make ids unique by
> adding a number where necessary, so the above example would become
>
>
> <div id="login_box">...</div>
> <div id="login_box_1">...</div>
> <div id="login_box_2">...</div>
> <div id="my_id">...</div>
> <div id="my_id_1">...</div>
>
> Are there any objections to this being applied?
>
> Thank you!
> (ab)
>
> --
> Arne Brasseur
> http://www.arnebrasseur.net
> http://www.zhongwiki.com
> http://www.bankske.org
> arne at arnebrasseur.net
>
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>



-- 
http://me.gr
http://joy.gr
http://cull.gr
http://nitroproject.org
http://phidz.com
http://joyerz.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20071127/2e496807/attachment.html 


More information about the Nitro-general mailing list