Update documentation to customize components
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Components
|
# Customizing 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:
|
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:
|
||||||
|
|
||||||
@@ -10,6 +10,8 @@ class Admin::TableActionsComponent
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Check the [models customization](models.md) section for more information about customizing Ruby classes.
|
||||||
|
|
||||||
If, on the other hand, you also want to customize the view, you need a small modification. Instead of the previous code, use:
|
If, on the other hand, you also want to customize the view, you need a small modification. Instead of the previous code, use:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -22,4 +24,4 @@ class Admin::TableActionsComponent
|
|||||||
end
|
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.
|
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, the same way you can [customize views](views.md).
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Componentes
|
# Personalización de 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:
|
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:
|
||||||
|
|
||||||
@@ -10,6 +10,8 @@ class Admin::TableActionsComponent
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Consulta la sección de [personalización de modelos](models.md) para más información sobre personalizar clases de Ruby.
|
||||||
|
|
||||||
Si, por el contrario, también quieres personalizar la vista, necesitas una pequeña modificación. En lugar del código anterior, utiliza:
|
Si, por el contrario, también quieres personalizar la vista, necesitas una pequeña modificación. En lugar del código anterior, utiliza:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -22,4 +24,4 @@ class Admin::TableActionsComponent
|
|||||||
end
|
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.
|
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, de la misma manera en que puedes [personalizar vistas](views.md).
|
||||||
|
|||||||
Reference in New Issue
Block a user