diff --git a/src/core/component/context.rs b/src/core/component/context.rs
index d27de662..d3b13cd3 100644
--- a/src/core/component/context.rs
+++ b/src/core/component/context.rs
@@ -3,7 +3,7 @@ use crate::core::component::{ChildOp, Component, MessageLevel, StatusMessage};
use crate::core::theme::all::DEFAULT_THEME;
use crate::core::theme::{ChildrenInRegions, DefaultRegion, RegionRef, TemplateRef, ThemeRef};
use crate::html::{Assets, Favicon, JavaScript, StyleSheet};
-use crate::html::{Markup, RoutePath, html};
+use crate::html::{Markup, Props, PropsOp, RoutePath, html};
use crate::locale::L10n;
use crate::locale::{LangId, LanguageIdentifier, RequestLocale};
use crate::web::HttpRequest;
@@ -137,6 +137,10 @@ pub trait Contextual: LangId {
#[builder_fn]
fn with_assets(self, op: AssetsOp) -> Self;
+ /// Modifica identificador, clases CSS o atributos HTML del elemento `
`.
+ #[builder_fn]
+ fn with_body_props(self, op: PropsOp) -> Self;
+
/// Añade un componente o aplica una operación [`ChildOp`] en la región por defecto del
/// documento.
#[builder_fn]
@@ -206,6 +210,9 @@ pub trait Contextual: LangId {
/// Devuelve los scripts JavaScript de los recursos del contexto.
fn javascripts(&self) -> &Assets;
+ /// Devuelve identificador, clases CSS y atributos HTML del elemento ``.
+ fn body_props(&self) -> &Props;
+
// **< Contextual HELPERS >*********************************************************************
/// Elimina un parámetro del contexto. Devuelve `true` si la clave existía y se eliminó.
@@ -284,6 +291,7 @@ pub struct Context {
favicon : Option, // Favicon, si se ha definido.
stylesheets: Assets, // Hojas de estilo CSS.
javascripts: Assets, // Scripts JavaScript.
+ body_props : Props, // Identificador, clases CSS y atributos del .
regions : ChildrenInRegions, // Regiones de componentes para renderizar.
params : HashMap<&'static str, (Box, &'static str)>, // Parámetros en ejecución.
id_counters: RefCell>, // RefCell permite mutar desde build_id(&self).
@@ -312,6 +320,7 @@ impl Context {
favicon : None,
stylesheets: Assets::::new(),
javascripts: Assets::::new(),
+ body_props : Props::default(),
regions : ChildrenInRegions::default(),
params : HashMap::default(),
id_counters: RefCell::new(HashMap::new()),
@@ -521,6 +530,12 @@ impl Contextual for Context {
self
}
+ #[builder_fn]
+ fn with_body_props(mut self, op: PropsOp) -> Self {
+ self.body_props.alter_prop(op);
+ self
+ }
+
#[builder_fn]
fn with_child(mut self, op: impl Into) -> Self {
self.regions
@@ -570,6 +585,10 @@ impl Contextual for Context {
&self.javascripts
}
+ fn body_props(&self) -> &Props {
+ &self.body_props
+ }
+
// **< Contextual HELPERS >*********************************************************************
fn remove_param(&mut self, key: &'static str) -> bool {
diff --git a/src/response/page.rs b/src/response/page.rs
index 57684365..129ccf03 100644
--- a/src/response/page.rs
+++ b/src/response/page.rs
@@ -89,7 +89,6 @@ pub struct Page {
description : Attr,
metadata : Vec<(&'static str, &'static str)>,
properties : Vec<(&'static str, &'static str)>,
- body_props : Props,
context : Context,
}
@@ -105,7 +104,6 @@ impl Page {
description : Attr::::default(),
metadata : Vec::default(),
properties : Vec::default(),
- body_props : Props::default(),
context : Context::new(Some(request)),
}
}
@@ -140,13 +138,6 @@ impl Page {
self
}
- /// Modifica identificador, clases CSS o atributos HTML del elemento ``.
- #[builder_fn]
- pub fn with_body_props(mut self, op: PropsOp) -> Self {
- self.body_props.alter_prop(op);
- self
- }
-
// **< Page GETTERS >***************************************************************************
/// Devuelve el título traducido para el idioma de la página, si existe.
@@ -169,11 +160,6 @@ impl Page {
&self.properties
}
- /// Devuelve identificador, clases CSS y atributos HTML del elemento ``.
- pub fn body_props(&self) -> &Props {
- &self.body_props
- }
-
/// Devuelve una referencia mutable al [`Context`] de la página.
///
/// El [`Context`] actúa como intermediario para muchos métodos de `Page` (idioma, tema,
@@ -305,6 +291,12 @@ impl Contextual for Page {
self
}
+ #[builder_fn]
+ fn with_body_props(mut self, op: PropsOp) -> Self {
+ self.context.alter_body_props(op);
+ self
+ }
+
#[builder_fn]
fn with_child(mut self, op: impl Into) -> Self {
self.context
@@ -348,6 +340,10 @@ impl Contextual for Page {
self.context.javascripts()
}
+ fn body_props(&self) -> &Props {
+ self.context.body_props()
+ }
+
// **< Contextual HELPERS >*********************************************************************
fn remove_param(&mut self, key: &'static str) -> bool {