Search code examples
ruby-on-railsrubyruby-on-rails-3haml

Rails with HAML template Engine how label works in Haml?


i am new to HAML and not able to understand old coder logic i try to identify where the label come on ui in HAML template this are my code main view page

  = render :partial => "application/select_search", :locals => {:n => "benefit_stream_inf", :options => @dynamic_benefit_options, :default => true}

select_search page which render in main plage

label = local_assigns[:l] ? l : t(n, :scope => local_assigns[:s] ? s : :models)

now i not give any label in render then how lable get generated

can some one explain this label assignment code

label = local_assigns[:l] ? l : t(n, :scope => local_assigns[:s] ? s : :models)

Solution

  • finally, I got my answer

    label = local_assigns[:l] ? l : t(n, :scope => local_assigns[:s] ? s : :models)
    

    local_assigns[:l] is a local variable which used to give label directly

    t(n, :scope => local_assigns[:s] ? s : :models) this is used for fatch label value of translation file with pass key and scope

    and translation file will put at config/local/en.yml