Method: ApplicationHelper#parse_sections

Defined in:
app/helpers/application_helper.rb

#parse_sections(text, project, obj, attr, only_path, options) ⇒ Object



1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
# File 'app/helpers/application_helper.rb', line 1393

def parse_sections(text, project, obj, attr, only_path, options)
  return unless options[:edit_section_links]

  text.gsub!(HEADING_RE) do
    heading, level = $1, $2
    @current_section += 1
    if @current_section > 1
      (
        'div',
        link_to(
          sprite_icon('edit', l(:button_edit_section)),
          options[:edit_section_links].merge(
            :section => @current_section),
          :class => 'icon-only icon-edit'),
        :class => "contextual heading-#{level}",
        :title => l(:button_edit_section),
        :id => "section-#{@current_section}") + heading.html_safe
    else
      heading
    end
  end
end