@@ -46,10 +46,6 @@ def config
4646 # For Content Security Policy nonces
4747 delegate :content_security_policy_nonce , to : :helpers
4848
49- # Config option that strips trailing whitespace in templates before compiling them.
50- class_attribute :__vc_strip_trailing_whitespace , instance_accessor : false , instance_predicate : false
51- self . __vc_strip_trailing_whitespace = false # class_attribute:default doesn't work until Rails 5.2
52-
5349 attr_accessor :__vc_original_view_context
5450
5551 # Components render in their own view context. Helpers and other functionality
@@ -611,14 +607,28 @@ def with_collection_parameter(parameter)
611607 #
612608 # @param value [Boolean] Whether to strip newlines.
613609 def strip_trailing_whitespace ( value = true )
614- self . __vc_strip_trailing_whitespace = value
610+ ViewComponent ::Deprecation . deprecation_warning (
611+ "strip_trailing_whitespace" ,
612+ %(
613+ Use the new component-local configuration option instead:
614+
615+ ```rb
616+ class #{ self . class . name } < ViewComponent::Base
617+ configure do |config|
618+ config.strip_trailing_whitespace = #{ value }
619+ end
620+ end
621+ ```
622+ )
623+ )
624+ configuration . strip_trailing_whitespace = value
615625 end
616626
617627 # Whether trailing whitespace will be stripped before compilation.
618628 #
619629 # @return [Boolean]
620630 def strip_trailing_whitespace?
621- __vc_strip_trailing_whitespace
631+ configuration . strip_trailing_whitespace
622632 end
623633
624634 # Ensure the component initializer accepts the
0 commit comments