Developer Tips: Extension Configuration
It’s not widely used (as far as I know) but did you know that extensions can alter the configuration of the application?
Yes, it’s true. All you need to do is:
class MyExtension < Radiant::Extension
extension_config do |config|
config.gem 'gem_name'
config.extension 'radiant-extension-name'
config.after_initialize do
puts "hello from MyExtension"
end
end
end
You can require ‘will_paginate’ for example. That’s right, no more instructions in the README file telling you to manually add some gem to your configuration.
The config.extension bit is primitive, but it has to be. Extensions don’t have a formal way to control versions, so you can’t just add config.extension 'rbac_base', :version => '99.3.157'. That won’t work. It will merely check to see that the extension with the given name exists and warn you if it doesn’t.
Why not load extensions as gems then? That would be great, and would likely help the development of new features for Radiant since we’d have better control over real versions for extensions. 2010 will certainly be an interesting year if some great developer from a great company can get Radiant to load extensions from gems.
Cheers to all the developers working to make Radiant even better. Happy new year!
