Class: Banzai::Filter::References::ProjectReferenceFilter

Inherits:
ReferenceFilter
  • Object
show all
Defined in:
lib/banzai/filter/references/project_reference_filter.rb

Overview

HTML filter that replaces project references with links.

Constant Summary

Constants inherited from ReferenceFilter

ReferenceFilter::REFERENCE_TYPE_DATA_ATTRIBUTE

Instance Method Summary collapse

Methods inherited from ReferenceFilter

call, #call, #call_and_update_nodes, #each_node, #group, #initialize, #nodes, #object_class, #project, #requires_unescaping?

Methods included from OutputSafety

#escape_once

Methods included from RequestStoreReferenceCache

#cached_call, #get_or_set_cache

Constructor Details

This class inherits a constructor from Banzai::Filter::References::ReferenceFilter

Instance Method Details

#references_in(text, pattern = object_reference_pattern) ⇒ Object

Public: Find ‘namespace/project>` project references in text

references_in(text) do |match, project|
  "<a href=...>#{project}></a>"
end

text - String text to search.

Yields the String match, and the String project name.

Returns a String replaced with the return of the block.



22
23
24
25
26
# File 'lib/banzai/filter/references/project_reference_filter.rb', line 22

def references_in(text, pattern = object_reference_pattern)
  text.gsub(pattern) do |match|
    yield match, "#{$~[:namespace]}/#{$~[:project]}"
  end
end