Class: Strelka::CMS::PageFilter::Strip
- Inherits:
-
Strelka::CMS::PageFilter
- Object
- Strelka::CMS::PageFilter
- Strelka::CMS::PageFilter::Strip
- Defined in:
- lib/strelka/cms/pagefilter/strip.rb
Overview
A class for stripping any remaining processing instructions from a .page file.
Constant Summary collapse
- ANY_PI_PATTERN =
PI ::= ‘<?’ PITarget (S (Char* - (Char* ‘?>’ Char*)))? ‘?>’
%r{ <\? (.*?) # PI content \?> }x
Instance Method Summary collapse
-
#process(source, page) ⇒ Object
Process the
page
‘s source with the filter and return the altered content.
Instance Method Details
#process(source, page) ⇒ Object
Process the page
‘s source with the filter and return the altered content.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/strelka/cms/pagefilter/strip.rb', line 17 def process( source, page ) self.log.debug "Stripping out any remaining PIs" comments = page.['comment_stripped_pis'] return source.gsub( ANY_PI_PATTERN ) do |m| if comments "<!-- Stripped PI: #$1 -->" else '' end end end |