Created
January 2, 2012 08:51
-
-
Save alexkravets/1549922 to your computer and use it in GitHub Desktop.
Custom Tags & Filters for LocomotiveCMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
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
Where did you put those files?