Add back app.set, but mark as deprecated
This commit is contained in:
parent
eb82f402a0
commit
6357f4f5b8
10
middleman-core/features/extension_api_deprecations.feature
Normal file
10
middleman-core/features/extension_api_deprecations.feature
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Feature: Extension author could use some hooks
|
||||||
|
|
||||||
|
Scenario: When build
|
||||||
|
Given a fixture app "extension-api-deprecations-app"
|
||||||
|
When I run `middleman build`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the output should contain "`set :layout` is deprecated"
|
||||||
|
And the file "build/index.html" should contain "In Index"
|
||||||
|
And the file "build/index.html" should not contain "In Layout"
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
class LayoutDisabler < Middleman::Extension
|
||||||
|
def initialize(app, options_hash = {}, &block)
|
||||||
|
super
|
||||||
|
|
||||||
|
app.set :layout, false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
::Middleman::Extensions.register(:layout_disabler, LayoutDisabler)
|
||||||
|
|
||||||
|
activate :layout_disabler
|
|
@ -0,0 +1 @@
|
||||||
|
In Index
|
|
@ -0,0 +1,3 @@
|
||||||
|
In Layout
|
||||||
|
|
||||||
|
<%= yield %>
|
|
@ -391,6 +391,21 @@ module Middleman
|
||||||
execute_callbacks(:before_shutdown)
|
execute_callbacks(:before_shutdown)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# Set attributes (global variables)
|
||||||
|
#
|
||||||
|
# @deprecated Prefer accessing settings through "config".
|
||||||
|
#
|
||||||
|
# @param [Symbol] key Name of the attribue
|
||||||
|
# @param value Attribute value
|
||||||
|
# @return [void]
|
||||||
|
def set(key, value=nil, &block)
|
||||||
|
logger.warn "Warning: `set :#{key}` is deprecated. Use `config[:#{key}] =` instead."
|
||||||
|
|
||||||
|
value = block if block_given?
|
||||||
|
config[key] = value
|
||||||
|
end
|
||||||
|
|
||||||
# Work around this bug: http://bugs.ruby-lang.org/issues/4521
|
# Work around this bug: http://bugs.ruby-lang.org/issues/4521
|
||||||
# where Ruby will call to_s/inspect while printing exception
|
# where Ruby will call to_s/inspect while printing exception
|
||||||
# messages, which can take a long time (minutes at full CPU)
|
# messages, which can take a long time (minutes at full CPU)
|
||||||
|
|
Loading…
Reference in a new issue