Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit d03c27b

Browse files
committed
Add #content_with_named_vars
1 parent 73328b1 commit d03c27b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/wpxf/core/data_file.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ def php_content
1313
content.strip.sub(/^<\?php/i, '').sub(/\?>$/i, '')
1414
end
1515

16+
# @return [String] the contents of the data file with variable replacements.
17+
def content_with_named_vars(vars)
18+
matcher = /#{vars.keys.map { |k| Regexp.escape(k) }.join('|')}/
19+
content.gsub(matcher, vars)
20+
end
21+
1622
# @return the content of the file.
1723
attr_accessor :content
1824
end

0 commit comments

Comments
 (0)