Liquid Markup Adapter Pattern For Rails Models

Liquid Markup is a way to build safe web page templates which protect the security of the web server. Ruby On Rails has a typical model like this:
  class Item < ActiveRecord::Basae
    ...
  end
Liquid Markup adds a mixin named liquid_methods that defines which methods are accessible via liquid:
  class Item < ActiveRecord::Basae
    ...
    liquid_methods :name, :description
    ...
  end
Instead of putting the Liquid Markup into the ActiveRecord class, we can use an adapter pattern:
  class Item < ActiveRecord::Basae
    include ItemToLiquidMarkupAdapter
  end

  module ItemToLiquidMarkupAdapter
    liquid_methods :name, :description
  end
Advantages:



What's Next?

blog comments powered by Disqus