Module: MarkdownRecord::ContentDsl::Fragment
- Included in:
- MarkdownRecord::ContentDsl
- Defined in:
- lib/markdown_record/rendering/content_dsl/fragment.rb
Constant Summary collapse
- REGEX =
/<!--\s*fragment\s*({[\s"'\\\w:,.\[\]\{\}_\/|\-]*})\s*-->/
- ENCODED_REGEX =
/<!--\s*fragment\s+({[\s"'\\\w:,.\[\]\{\}_\/|\-]*})\s*-->/
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.remove_dsl(text) ⇒ Object
17 18 19 |
# File 'lib/markdown_record/rendering/content_dsl/fragment.rb', line 17 def self.remove_dsl(text) text.gsub(REGEX, "").gsub(ENCODED_REGEX, "") end |
Instance Method Details
#fragment_dsl(text) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/markdown_record/rendering/content_dsl/fragment.rb', line 7 def fragment_dsl(text) match = text.match(REGEX) if match JSON.parse(match[1]) else nil end end |