ViewComponent::Base itself will always use the defaults. Any classes inheriting from ViewComponent::Base will cascade config down using InheritableOptions, only specifying any overrides.
Generate options being on their own "layer of config is currently unresolved - it might be that config needs to be a new object inheriting from InheritableOptions that has method accessors for everything in that namespace.
It seems like this solution is now applicable to everything, not just strict_helper_enabled?
ViewComponent::Base itself will always use the defaults. Any classes inheriting from ViewComponent::Base will cascade config down using InheritableOptions, only specifying any overrides.
Generate options being on their own "layer of config is currently unresolved - it might be that config needs to be a new object inheriting from InheritableOptions that has method accessors for everything in that namespace.
This was initially written to support extracting the incoming strict_helpers_enabled? option, but applies to everything.
* Add template information to multiple template error messages.
In service of helping debug https://github.com/ViewComponent/view_component/issues/2114,
this change fleshes out the template error messages to include
the current list of templates.
* add newline
* Re-add `@private`, undocumented `.identifier` method that was only meant for internal framework use but was used by some downstream consumers. This method will be removed in a coming minor release.
* add nocov marks
* Add basic internal testing for memory allocations
* add RUBY_VERSION to debug output
* fix allocation counts
* fix allocation counts
* use compile cache helper
* try using cache clearing
* try using more specific ruby version targets and ensure compilation
* add allocation counts for CI ruby versions
* use counts from CI
* move require to top of file
* try removing component from compile cache to stabilize allocations
* another stabilization attempt
* add test case
* two tests remaining
* first time all green
* Fix final line endings
* add docs, changelog, test helpers
* Fix final line endings
* streamline compiler method generation
* simplification
* refactor to remove index usage
* clearer control flow
* lint
* md lint
* remove remaining hardcoded formats
* Update lib/view_component/base.rb
Co-authored-by: Blake Williams <blakewilliams@github.com>
* remove unnecessary `inspect`
* remove unused `identifier`
* inline single-use method
* add safe navigation
* consolidate template collision error messages to include format
* add backticks around variant name in error
* use one line syntax
* no need to return false
* inline single-use method
* remove offhand comment that would be better in the compiler, if at all
* inline barely used variable
* consolidate safe_class_name into default_method_name
* use shorter `component` instead of `component_class`
* remove unnecessary conditional
* remove unnecessary nesting
* inline single use method
* remove intermediate compiler methods
* InlineTemplate is now included by default
* move comment to be in correct location
* start to make inline templates like other templates
* continue to consolidate inline template logic
* inline templates are just templates
* move lock to outside conditional
* use same method_name definition
* all templates have line numbers
* move towards single method definition path with source
* template handler is already present, no need to re-calculate
* just pass the template around instead of four params
* use single class_eval to define template methods
* remove unnecessary skipping of iterator
* make template hashes look the same
* move default slot registration to Slotable
* define render_template_for in one place
* remove duplicated method name construction
* sort nils last
* consolidate construction of safe_name
* inline single-use method that at minimum should have been private
* method name should not depend on templates state
* set method name on template hash
* use method name from template hash
* shorten to one-line
* move conditional into existing file template conditional
* simplify `templates
* remove unused formats method
* always set @templates at the same point vs. lazily
* move compiled_template to Template
* clean up method name duplication
* more clearly identify method name
* move compile_to_component to Template
* construct template objects
* use template object in more places
* move html format check to template
* use format accessor on template
* move variant access to template
* remove uses for method name from hash
* use template object in more locations
* use template object in more places
* use existing template object
* add comment for reload functionality
* no more template hash!
* do not define branches if it's not used
* use single code path for safe method definition for templates
* consolidate render_template_for duplication
* consolidate to one-liner
* consolidate to one-liner
* pass redefinition lock to template
* use template object for inline templates in render_template_for
* remove unused method definition
* simplify error check
* use default method name in fewer cases
* remove unreachable code
* remove method name logic from compiler
* simplify lookup of variants
* inline variants accessor
* remove duplicative normalized_variant_name
* add note about allowing inline_call / template collision
* remove usage of inline_calls_defined_on_self
* remove inline_calls_defined_on_self
* inline_calls is only used once
* add todo around tracking template rendering
* simplify conditional to use templates
* simplify conditional
* make one-liner
* gather_template_errors explicitly
* use attr_reader to match templates
* move logic into template error construction
* couple template compilation with render method definition
* define safe method as part of compilation
* extract Template#inline_call?
* inline inline_calls helper
* use select instead of conditonal map+compact
* simplify logic and naming in duplicate detection
* use more specific naming for variant pairs
* inline
* passing around redef lock was messy
* initializer is longer than 120 chars
* let Ruby construct symbol string
* simplify branch construction
* assign body as result of conditionals
* use each_with_object to simplify
* use syntactic sugar
* naming, method privacy
* use default values
* inline inline_calls
* standardrb
* remove out-of-date comment
* shorten lines
* use .first
* remove attr_reader
* simplify compiler mode to be boolean
* remove attr_reader
* extract constant for default format
* split conditional into two lines for readibilty
* rename compiler mode to development mode
* use any? with method extracted to template
* avoid use of _1
* avoid use of _1
* move Template to its own file
* extract simplest case to conditional
* Fix final line endings
* avoid block variable
* avoid more block variables
* standardrb
* add comment
* memoize instance methods lookup
* memoize instance method check
* use single line for each argument
* add TODO for HTML output safety check
* extract and comment format and variant derivation from path
* simpler extension extraction
* add explainer comments for format and variant extraction
* use Hash with Set value to find conflicting variants
* use single loop instead of two
* standardrb
* indicate constant is in internal
* move redefinition lock back to compiler
* remove loop
---------
Co-authored-by: GitHub Actions Bot <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Blake Williams <blakewilliams@github.com>
* add test case
* two tests remaining
* first time all green
* Fix final line endings
* add docs, changelog, test helpers
* Fix final line endings
* streamline compiler method generation
* simplification
* refactor to remove index usage
* clearer control flow
* lint
* md lint
* remove remaining hardcoded formats
* Update lib/view_component/base.rb
Co-authored-by: Blake Williams <blakewilliams@github.com>
* remove unnecessary `inspect`
* remove unused `identifier`
* inline single-use method
* add safe navigation
* consolidate template collision error messages to include format
* add backticks around variant name in error
* compiler should check for variant/format render combinations
* standardrb
---------
Co-authored-by: GitHub Actions Bot <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Blake Williams <blakewilliams@github.com>
* Register stats directories with Rails::CodeStatistics.register_directory.
Rails `main` uses Thor for the `bin/rails stats` command instead of
Rake. This means stats directories need to be added in the Railtie.
The global constant STATS_DIRECTORIES defined by Rails, has been
deprecated in favor of Rails::CodeStatistics.register_directory.
8c7754dfdf/railties/CHANGELOG.md?plain=1#L1-L11
* add changelog
* Update docs/CHANGELOG.md
---------
Co-authored-by: Joel Hawksley <joel@hawksley.org>
Co-authored-by: Joel Hawksley <joelhawksley@github.com>
* Add distinct GeneratedSlotMethods module to ViewComponents and define `#{slot}` and `#{slot?}` methods on this module, allowing these methods to be overridden with access to `super` implementation.
* Update docs/CONTRIBUTING.md
* Update docs/CHANGELOG.md
---------
Co-authored-by: Joel Hawksley <joelhawksley@github.com>
Co-authored-by: Joel Hawksley <joel@hawksley.org>
* Add module namespacing to generated components and other files
First step to add support for using view components in rails engine
* Config#default_preview_paths should include preview paths generated for rails engine
* Add some dummy tests
* Create test group for engine tests
* Fix test and simplecov setup for engine tests
* Tweak tests
* Allow to run tests with 'm' ;)
* Fix tests
* Improve tests
* Fix preview paths
* Return unique values for default_preview_path
* One step closer with tests
* Remove trailing whitespaces
* Update CHANGELOG
* Update contributors list
* Remove .keep
* Update changelog - be more precise in changes description
* Don't wrap with module namespace in tests and specs
Instead of wraping test/spec with module namespacing
pass module namespace inline with described class
* Rename Dummy => TestEngine
---------
Co-authored-by: Joel Hawksley <joel@hawksley.org>