Initialize the references result Hash in ReferenceFilter

This commit is contained in:
Robert Speicher 2015-04-15 14:21:20 -04:00
parent 439b9f50af
commit 879be42862

View file

@ -12,7 +12,15 @@ module Gitlab
# :reference_class - Custom CSS class added to reference links.
# :only_path - Generate path-only links.
#
# Results:
# :references - A Hash of references that were found and replaced.
class ReferenceFilter < HTML::Pipeline::Filter
def initialize(*args)
super
result[:references] = Hash.new { |hash, type| hash[type] = [] }
end
def escape_once(html)
ERB::Util.html_escape_once(html)
end
@ -29,6 +37,14 @@ module Gitlab
context[:project]
end
# Add a reference to the pipeline's result Hash
#
# type - Singular Symbol reference type (e.g., :issue, :user, etc.)
# value - Object to add
def push_result(type, value)
result[:references][type].push(value)
end
def reference_class(type)
"gfm gfm-#{type} #{context[:reference_class]}".strip
end