This gem was extraced from SalesKing where it handles placeholders substitution for user supplied email-, text- and export- templates.
Define the available methods in your class
class User include KingPlaceholder has_many :comments has_placeholders :firstname end class Comment include KingPlaceholder has_placeholders :text end
Use placeholder names in square brackets:
@user.expand_placeholders("Hello [user.first_name]") => Hello Schorsch
It can also handle relations and collections
@user.expand_placeholders("[comments][text][/comments]") => All comment texts @user.expand_placeholders("[comments.1.text]") => First comment text
This gems still relies on king_views with king_format, for money, date formatting. We will outsource king_format into its own gem and remove more SalesKing internal dependencies.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install king_placeholder
Create your feature branch (`git checkout -b my-new-feature`)
Commit your changes (`git commit -am 'Added some feature'`)
Push to the branch (`git push origin my-new-feature`)
Create new Pull Request