Resources

Summary

# Gemfile
  gem 'florrick'

Passing a block into the florrick method.

# user.rb
  class User < ActiveRecord::Base
    florrick do
      string :first_name, :last_name
      string(:full_name) { "#{first_name} #{last_name}"}
      string(:age) { Date.today.year - birthday.year - (birthday.to_date.change(year: Date.today.year) > Time.now ? 1 : 0)}
    end
  end

  # {{user.full_name}}

In the Rails console, we saw how the options are passed through Florrick.convert to interpret the strings and replace them with our dynamic content.

# console
  string = "Happy Birthday {{user.full_name}}."
  string = "Happy Birthday {{user.full_name}}. You are now {{user.age}} years old!"
  Florrick.convert(string, user: user)