Extract method to provide a title for SDG pages

This way we'll avoid the duplication that can be found in the admin
section.
This commit is contained in:
Javi Martín
2020-11-20 17:25:36 +01:00
parent a42cb050a7
commit cb78a254f4
3 changed files with 14 additions and 5 deletions

View File

@@ -1,8 +1,4 @@
<% provide(:title) do %> <%= header %>
<%= t("sdg_management.header.title") %> - <%= title %>
<% end %>
<h2><%= title %></h2>
<table> <table>
<thead> <thead>

View File

@@ -1,4 +1,6 @@
class SDGManagement::Goals::IndexComponent < ApplicationComponent class SDGManagement::Goals::IndexComponent < ApplicationComponent
include SDGManagement::Header
attr_reader :goals attr_reader :goals
def initialize(goals) def initialize(goals)

View File

@@ -0,0 +1,11 @@
module SDGManagement::Header
extend ActiveSupport::Concern
def header
provide(:title) do
"#{t("sdg_management.header.title")} - #{title}"
end
tag.h2 title
end
end