The question says a 1000 words but what I basically want to do is build a Locomotive CMS plugin and I am stuck at the basics. Which is not such a good thing.
I have followed the instructions of this gem because it's the only piece of reference I could find: https://github.com/colibri-software/locomotive_plugins
I've added locomotive_plugins
to my gemfile. I made a file called locomotive_test_plugin.rb
and placed it in my lib
folder (I found this a logical place to put this file because it doesn't say clearly in the gem instructions). I did add the lib
folder to the config.autoload_paths
in the application.rb
. And I kind of hoped that it would work
The locomotive_test_plugin.rb looks like
class LocomotiveTestPlugin
include Locomotive::Plugin
def initialize_plugin
# Custom initialization code
end
def to_liquid
{:test => "test"}
end
end
LocomotivePlugins::register_plugin(LocomotiveTestPlugin, "test_plugin")
Turns out it didn't. I also made a custom gem
called locomotive_test_plugin
and installed the gem and added that gem to the Gemfile like:
source 'https://rubygems.org'
gem 'locomotive_cms', '~> 2.0.1', :require => 'locomotive/engine'
gem 'locomotive_plugins'
group :assets do
gem 'compass-rails', '~> 1.0.2'
gem 'sass-rails', '~> 3.2.4'
gem 'coffee-rails', '~> 3.2.2'
gem 'uglifier', '~> 1.2.4'
# If you run your engine on **Linux,** you also have to add the following gem
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
end
group :development do
gem 'unicorn'
end
group(:locomotive_plugins) do
gem 'locomotive_test_plugin'
end
According to the gem I can now edit any page in the CMS and add the following piece of liquid code:
{{ plugins.test_plugin.test }}
And I would expect the output to be 'test' but instead it shows nothing. It also doesn't display any errors like 'plugin not found' or something similar.
I've restarted the local server if someone would suggest that.
But where in the process did I went wrong - can anyone enlighten me on this problem.