metadata - including rails object in meta tags keywords -


i'd include rails object in keywords straight text code not right way it...how can this?

set_meta_tags :keywords => %w[keyword1 keyword2 #{params[:hospital]}] 

you might want have @ 2 plug-ins including rails object in meta tags:

meta magic: https://github.com/lassebunk/metamagic

head liner: https://github.com/mokolabs/headliner

edit: meta tag gem

what write meta helper stick in applicationhelper, looks this:

def meta(field = nil, list = [])   field = field.to_s   @meta ||= {     'robots' => ['all'],     'copyright' => ['my copyright'],     'content-language' => ['en'],     'title' => [],     'keywords' => []   }    if field.present?     @meta[field] ||= []     case list.class       when array         @meta[field] += list       when string         @meta[field] += [list]       else         @meta[field] += [list]     end      case field       when 'description'         content = truncate(strip_tags(h(@meta[field].join(', '))), :length => 255)       else         content = @meta[field].join(', ')     end      return raw(%(<meta #{att}="#{h(field)}" content="#{h(content)}"/>))   else     tags = ''     @meta.each |field, list|       tags += meta(field)+"\n"     end     return tags.rstrip   end end 

you can set meta tags in views, adding call meta() in it. in articles/show.html.erb might add top of view:

<% meta(:title, @article.title) %> 

and in layouts, add without parameters, it'll spit out meta tags.

<%= meta %> 

or have output individual tag:

<%= meta(:title) %> 

i bet there's more elegant solutions, though.

but if looking implemented in rails you're out of luck.

thanks.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -