lib/middleman-cells/extension.rb in middleman-cells-0.0.2 vs lib/middleman-cells/extension.rb in middleman-cells-0.0.3
- old
+ new
@@ -33,10 +33,11 @@
end
def after_configuration
cells_dir = File.join(app.root, app.config[:source], options.cells_dir)
helper_modules = app.template_context_class.included_modules
+ app_proxy = app
# Extending Cell::ViewModel to adapt Middleman
::Cell::ViewModel.class_eval do
self.view_paths << cells_dir
@@ -44,9 +45,15 @@
def current_engine
end
# Include view helpers
helper_modules.each {|helper| include helper }
+
+ # Shortcut to global values on the app instance
+ globals = %i[config logger sitemap server? build? environment? data extensions root]
+ globals.each do |name|
+ define_method(name) { app_proxy.send(name) }
+ end
end
if options.autoload
require 'active_support/dependencies'
::ActiveSupport::Dependencies.autoload_paths << cells_dir