Hi, I have seen this into the "nitro real example"
def index #... end ann :index, :title => 'All categories'
but I don't understand how use it. Is it correlated with the helper :sitemap? Where I find a small example?
Thanks
(1 attempts)
Kashia answered:
Annotations basically provide a way to 'annotate' :symbols on class scope with information.
Most basic usage:
class SomeKlass ann :index, :some => :symbol def test p ann(:index) end end
So, you always use .ann on a class (never on a instance).
Code tailored to the :title:
class MyController < Nitro::Controller def index # ... end ann :index, :title => 'All Categories' end class Page < Nitro::Element def render title = "Nitro::Controller.current.ann(@action_name.to_sym)[:title]" out = %{ <html> <head><title>\#{#{title}}</title></head> <body> #{content} </body> </html> } end end
Note especially here the escaped 'string input'. I haven't actually tested this code, but I hope it does work like this.
What it does, it takes the annotation from the :index symbol and just puts it there in the between the title tags.
That is not all there is to say about annotations, it is a magic box full of wonders, so I'll leave that to a full tip, after I talk with Trans again...