Newbie question

Can any tell me what this should be doing? What does [:sidebar_title]
do?

<%= ‘here is a title’[:sidebar_title] %>

Thanks!
JB

That is not correct syntax. It looks like you are missing the name of
the hash. I should look something like:

<%= 'here is a title ’ + some_hash[:sidebar_title] %>

Where some_hash is a hash defined in your controller. If you pasted the
code from your controller, I could help you further.

I agree, it doesn’t look like correct syntax. The code is from the
beast forum.
All the code is available here:
http://svn.techno-weenie.net/projects/beast/trunk/
They use syntax like that in the view all over the place:
<%= ‘What is Beast?’[:beast_sidebar_title] %>
The views are in .html.erb files.

FYI - figured this out. This is an example of the syntax used if you
are using the Gibberish plugin. It is a localization library used for
doing translation to other languages, defining repetition strings,
etc.

If you want more info there is a really quick and informative
introduction here:
http://plugins.require.errtheblog.com/browser/gibberish/README

That makes sense, just looks strange at first glance. I haven’t had to
deal with internationalization yet luckily.

I haven’t looked in depth at the Beast code, but that looks like it’s
there for internationalization. Cf. the Gibberish plugin [1], which
overrides String#[] for this purpose. :sidebar_title is an index into a
translation table (for other languages), while the string is there so
that English-speaking developers can modify without breaking too much
flow.

[1] http://errtheblog.com/post/4396

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs