Skip to content

link_to_gfm, think twice [Meta]

Description

link_to_gfm has been a good wrap helper of link_to(gfm()), but cost of this helper is too high by two aspects:

This is a proposal to define a simple guideline to use the link_to_gfm helper.

Proposal

  • A single call of link_to_gfm is recommended only if GFM is effective in that context.
    • Consider to use link_to when GFM is not necessary.
  • Calling link_to_gfm in a loop is avoided without special reasons.
    • Use link_to almost always.

Current situation

path (in /app/views) 1st argument of link_to_gfm controller#action 1 or N issues/MRs status
/projects/blame/show.html.haml commit.title (updated by !12900 (merged)) truncate(commit.title, length: 35) Projects::BlameController#show N - (cf. #35163 (closed)) (introduced in eb06dd79) -
/projects/branches/_commit.html.haml commit.title Projects::BranchesController#index, Projects::TagsController#index, Projects::TagsController#show N - -
/projects/commits/_commit.html.haml commit.title Projects::CommitsController#show etc. N or 1 - (cf. #34509 (closed)) -
/projects/commits/_inline_commit.html.haml commit.title Projects::CompareController#show N - -
/projects/deployments/_commit.html.haml commit_title Projects::EnvironmentsController#show N - -
/projects/tree/_tree_commit_column.html.haml commit.full_title Projects::RefsController#logs_tree.json N - -
/shared/projects/_project.html.haml project.commit.title Projects::ForksController#index N #35742 (closed) !13173 (closed)
/shared/milestones/_issuable.html.haml issuable.title Projects::MilestonesController#show, Groups::MilestonesController#show, Explorer::MilestonesController#show N #34289 (closed) !12444 (merged)
/projects/issues/_merge_requests.html.haml merge_request.title Projects::IssuesController#show N !12451 (merged)
/shared/milestones/_milestone.html.haml milestone.title Projects::MilestonesController#index, Groups::MilestonesController#index, Explorer::MilestonesController#index N !12451 (merged)

Links / references

This was found when working on !12444 (merged) and !12451 (merged).

Edited by Takuya Noguchi