-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,
For the second problem, I believe the nicest default is to keep the "model name", because it really helps the user to know what kind of record he is looking at. I don't know if I understood the problem correctloy, but why don't we use two different translation tags, instead of a combined one? Something like: <ht key="<%= model_key %>.show.title"></ht> <ht key="<%= model_key %>.show.heading><name/></ht> What do you think? Regards, Ignacio El 26/08/11 17:36, Matt Jones escribió: > > On Aug 16, 2011, at 8:11 PM, Arthur Baldwin wrote: > >> I would very much like to hear from an expert in regard to this problem. At >> least let me know if this is considered a bug or not. >> At least that way, I can focus my attention on something else until it is >> resolved. >> >> Arthur >> >> From: Arthur Baldwin <[email protected]> >> To: "[email protected]" <[email protected]> >> Sent: Tuesday, August 16, 2011 2:25 PM >> Subject: Re: [Hobo Users] Possible Bug in Hobo 1.3 >> >> If anyone knows of another addition that I can add to the following code in >> order to make the "show page" display "Arthur E. Baldwin" instead of >> "Customer"....I would appreciate it very much if you could let me know what >> that syntax looks like. >> >> fields do >> fullname :string, :name => true >> address :string >> timestamps >> end > > Alright, got some time to poke around and here's what I found. The generated > code (from pages.dryml) looks like this: > > <h2 param="heading"> > <ht key="<%= model_key %>.show.heading" > name="&this.respond_to?(:name) ? this.name : ''"> > <name/> > </ht> > </h2> > > The relevant part from the generated hobo.en.yml: > > show: > title: "%{model}" > heading: "%{model} %{name}" > > The first problem is that the code that sets the name attribute being passed > to ht isn't nearly as general as the code that <name /> would run in the > absence of a translation. (the name tag handles name_attribute correctly) > > The second issue is that, even given a model that actually responds to > 'name', the translation doesn't match the un-translated version since there's > that extra %{model} in there. > > To resolve the first problem, I think we need a new helper 'name_for': > > def name_for(obj) > if (name_attr = obj.class.try_name_attribute) > obj.send(name_attr) > else > obj.try.name > end > end > > This would convert the pages.dryml code to: > > <h2 param="heading"> > <ht key="<%= model_key %>.show.heading" name="&name_for(this)"> > <name/> > </ht> > </h2> > > As to the second one, that's mostly a question of style. It would match the > code inside the <ht> if we changed en.hobo.show.heading to just '%{name}' - > thoughts? > > --Matt Jones > - -- Ignacio Huerta Arteche http://www.ihuerta.net Teléfono: 0034 645 70 77 35 Email realizado con software libre -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk5ZBDkACgkQBPlUJ6RHaOSfqQCdEtjZHFp31oSN+kYponwPvnQl rbwAnjytyro8QXv9Mv6+4v2+UEf3TCpf =VmcB -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
