module SnippetFilter def render_snippet(snippet_name) snippet = Snippet.first(:conditions => {:name => snippet_name}) if snippet return Liquid::Template.parse( snippet.content ).render else return t('nothing') end end def ruling_snippet(snippet_name) case snippet_name when 'language_bar' site = Site.first @site_in_use_locales = site.in_use_locales @site_valid_locales = site.valid_locales end return Liquid::Template.parse( eval(File.open("#{RAILS_ROOT}/lib/snippets/#{snippet_name}.snippet").read) ).render end end Liquid::Template.register_filter(SnippetFilter)