diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-04-15 00:37:41 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-04-15 00:37:41 -0400 |
commit | 3eefac61617889e29cc8c48181692f668558aa28 (patch) | |
tree | c40949540c8ba89deb06d35bd2cea2a659cfdf5d /lib/sisu/v3/param.rb | |
parent | debian/changelog (3.2.2-1) (diff) | |
parent | v3: vim syntax highlighting, document header added (@make:) :substitute: (diff) |
Merge tag 'sisu_3.2.3' into debian/sid
Diffstat (limited to 'lib/sisu/v3/param.rb')
-rw-r--r-- | lib/sisu/v3/param.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 5563f780..60f5345b 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -803,6 +803,26 @@ module SiSU_Param else nil end end + def substitute + m=@h['substitute'] + z=if m + w=m.scan(/\/(.+?)\/(i?,)\s*'(.+?)'(?:\s+|\s*;\s*|$)/) + arr_hash=[] + matches='' + w.each do |x| + c=(x[1] =~/[i],/) ? :i : :s + matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' + arr_hash << { + match: x[0].gsub(/([${}])/,'\\\\\1'), + replace: x[2], + case_s: c + } + end + matches.chop! + { match_and_replace: arr_hash, matches: matches } + else nil + end + end def plaintext_wrap if @h['plaintext_wrap'].to_s =~/\d\d+/ \ and @h['plaintext_wrap'].to_i > 19 \ |