Merge pull request #104 from consul/customize-components
Add documentation with recommendations for component customization
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
* [Views & Styles](en/customization/views_and_styles.md)
|
||||
* [Javascript](en/customization/javascript.md)
|
||||
* [Models](en/customization/models.md)
|
||||
* [Components](en/customization/components.md)
|
||||
* [Gems](en/customization/gems.md)
|
||||
* [Overwritting Application](en/customization/overwritting.md)
|
||||
|
||||
@@ -85,6 +86,7 @@
|
||||
* [Vistas & Estilos](es/customization/views_and_styles.md)
|
||||
* [Javascript](es/customization/javascript.md)
|
||||
* [Modelos](es/customization/models.md)
|
||||
* [Componentes](es/customization/components.md)
|
||||
* [Gemas](es/customization/gems.md)
|
||||
* [Adaptar la aplicación](es/customization/overwritting.md)
|
||||
|
||||
|
||||
25
docs/en/customization/components.md
Normal file
25
docs/en/customization/components.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Components
|
||||
|
||||
For components, customization can be used to change both the logic (included in a `.rb` file) and the view (included in a `.erb` file). If you only want to customize the logic for, let's say, the `Admin::TableActionsComponent`, create a file named `app/components/custom/admin/table_actions_component.rb` with the following content:
|
||||
|
||||
```ruby
|
||||
require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s
|
||||
|
||||
class Admin::TableActionsComponent
|
||||
# Your custom logic here
|
||||
end
|
||||
```
|
||||
|
||||
If, on the other hand, you also want to customize the view, you need a small modification. Instead of the previous code, use:
|
||||
|
||||
```ruby
|
||||
class Admin::TableActionsComponent < ApplicationComponent; end
|
||||
|
||||
require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s
|
||||
|
||||
class Admin::TableActionsComponent
|
||||
# Your custom logic here
|
||||
end
|
||||
```
|
||||
|
||||
This will make the component use the view in `app/components/custom/admin/table_actions_component.html.erb`. You can create this file and customize it to your needs.
|
||||
@@ -6,5 +6,6 @@
|
||||
* [Views & Styles](views_and_styles.md)
|
||||
* [Javascript](javascript.md)
|
||||
* [Models](models.md)
|
||||
* [Components](components.md)
|
||||
* [Gems](gems.md)
|
||||
* [Overwritting Application](overwritting.md)
|
||||
|
||||
25
docs/es/customization/components.md
Normal file
25
docs/es/customization/components.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Componentes
|
||||
|
||||
En el caso de los componentes, la personalización puede utilizarse para cambiar tanto la lógica (incluida en un archivo `.rb`) como la vista (incluida en un archivo `.erb`). Si solo quieres personalizar la lógica, por ejemplo del componente `Admin::TableActionsComponent`, crea el archivo `app/components/custom/admin/table_actions_component.rb` con el siguiente contenido:
|
||||
|
||||
```ruby
|
||||
require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s
|
||||
|
||||
class Admin::TableActionsComponent
|
||||
# Tu lógica personalizada aquí
|
||||
end
|
||||
```
|
||||
|
||||
Si, por el contrario, también quieres personalizar la vista, necesitas una pequeña modificación. En lugar del código anterior, utiliza:
|
||||
|
||||
```ruby
|
||||
class Admin::TableActionsComponent < ApplicationComponent; end
|
||||
|
||||
require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s
|
||||
|
||||
class Admin::TableActionsComponent
|
||||
# Tu lógica personalizada aquí
|
||||
end
|
||||
```
|
||||
|
||||
Esto hará que el componente utilice la vista en `app/components/custom/admin/table_actions_component.html.erb`. Puedes crear este archivo y personalizarlo según tus necesidades.
|
||||
@@ -6,5 +6,6 @@
|
||||
* [Vistas & Estilos](views_and_styles.md)
|
||||
* [Javascript](javascript.md)
|
||||
* [Modelos](models.md)
|
||||
* [Componentes](components.md)
|
||||
* [Gemas](gems.md)
|
||||
* [Adaptar la aplicación](overwritting.md)
|
||||
|
||||
Reference in New Issue
Block a user