Filter _Template content. Resolves #1603 and #1640. (#1612)

* Filter _Template content. Resolves #1603 and #1640.

* Introduces a Gollum::TemplateFilter class with methods to easily add _Template Filters.

* Adds support for relative _Template pages with fallback to _Template in root.
This commit is contained in:
Bart Kamphorst
2020-12-26 14:10:02 +01:00
committed by GitHub
parent 97ed5a7c57
commit 6c0796733d
3 changed files with 23 additions and 5 deletions
+16
View File
@@ -33,4 +33,20 @@ module Gollum
super(message || "Cannot write #{@dir}/#{@attempted_path}, found #{@dir}/#{@existing_path}.")
end
end
class TemplateFilter
@@filters = {}
def self.add_filter(pattern, &replacement)
@@filters[pattern] = replacement
end
def self.apply_filters(data)
@@filters.each do |pattern, replacement|
data.gsub!(pattern, replacement.call)
end
data
end
end
end