Skip to content

Instantly share code, notes, and snippets.

@alexkravets
Created January 2, 2012 08:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkravets/1549922 to your computer and use it in GitHub Desktop.
Save alexkravets/1549922 to your computer and use it in GitHub Desktop.
Custom Tags & Filters for LocomotiveCMS
module Locomotive
module Liquid
module Filters
# Module with custom filters
module Blog
# Creates a list of tags from a tags string, tags separated by comma
def tags(tags_string)
tags_string.split(', ').collect{|t| '<li><a href="/blog/tags/'+t+'" title="'+t.capitalize+'">'+t+'</a></li>'}.join()
end
# Register filter
::Liquid::Template.register_filter(Blog)
end
end
end
end
module LocomotiveBlog
class Engine < Rails::Engine
def self.activate
require 'locomotive/liquid/drops/base'
# Load template tags and filters
%w{. tags drops filters}.each do |dir|
Dir[File.join(File.dirname(__FILE__), 'locomotive', 'liquid', dir, '*.rb')].each do |lib|
Rails.env.production? ? require(lib) : load(lib)
end
end
end
config.to_prepare &method(:activate).to_proc
end
end
@ChiangChu
Copy link

Where did you put those files?

@alexkravets
Copy link
Author

Looks like I have them in /lib folder and then include in config/application.rb:

module Lovell
  class Application < Rails::Application
    [HERE]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment