diff options
Diffstat (limited to 'lib/gitlab/markdown/reference_filter.rb')
-rw-r--r-- | lib/gitlab/markdown/reference_filter.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/markdown/reference_filter.rb b/lib/gitlab/markdown/reference_filter.rb index a84bacd3d4f..47ee1d99da3 100644 --- a/lib/gitlab/markdown/reference_filter.rb +++ b/lib/gitlab/markdown/reference_filter.rb @@ -21,6 +21,22 @@ module Gitlab result[:references] = Hash.new { |hash, type| hash[type] = [] } end + # Returns a data attribute String to attach to a reference link + # + # id - Object ID + # type - Object type (default: :project) + # + # Examples: + # + # data_attribute(1) # => "data-project-id=\"1\"" + # data_attribute(2, :user) # => "data-user-id=\"2\"" + # data_attribute(3, :group) # => "data-group-id=\"3\"" + # + # Returns a String + def data_attribute(id, type = :project) + %Q(data-#{type}-id="#{id}") + end + def escape_once(html) ERB::Util.html_escape_once(html) end |