Class: Decidim::ContentParsers::TagParser
- Inherits:
-
BaseParser
- Object
- BaseParser
- Decidim::ContentParsers::TagParser
- Defined in:
- decidim-core/lib/decidim/content_parsers/tag_parser.rb
Overview
A parser that searches specific tags in the content. This is an abstract class that provides some helper methods for parsing the content and the implementation has to be defined by all the classes that inherit from this class.
Direct Known Subclasses
Constant Summary
Constants inherited from BaseParser
Instance Attribute Summary
Attributes inherited from BaseParser
Instance Method Summary collapse
-
#rewrite ⇒ String
Replaces tags name with new or existing tags models global ids.
Methods inherited from BaseParser
Methods included from Decidim::ContentProcessor::Common
#html_content?, #html_fragment
Constructor Details
This class inherits a constructor from Decidim::ContentParsers::BaseParser
Instance Method Details
#rewrite ⇒ String
Replaces tags name with new or existing tags models global ids.
The actual tags depend on the context, these can be hashtags, user mentions, user group mentions, etc.
18 19 20 21 22 23 24 25 26 27 |
# File 'decidim-core/lib/decidim/content_parsers/tag_parser.rb', line 18 def rewrite if html_content? html_fragment.search("span[data-type='#{tag_data_type}']").each do |el| el.replace (element_tag(el)) end html_fragment.to_s else (content) end end |