Method: Flukso::FluksoDB.fill_template
- Defined in:
- lib/flukso/database.rb
.fill_template(templateStr, values) ⇒ Object
See: freshmeat.net/articles/templates-in-ruby template: Returns a string formed from a template and replacement values
templateStr - The template string (format shown below) values - A hash of replacement values
Example format:
"Dear :::customer:::,\nPlease pay us :::amount:::.\n"
The “customer” and “amount” strings are used as keys to index against the values hash.
66 67 68 69 70 71 72 |
# File 'lib/flukso/database.rb', line 66 def self.fill_template( templateStr, values ) outStr = templateStr.clone() values.keys.each { |key| outStr.gsub!( /:::#{key}:::/, values[ key ] ) } outStr end |