💬 Corrige referencias en macros

This commit is contained in:
Manuel Cillero 2022-11-13 19:17:15 +01:00
parent e38cfca945
commit 12d79c8437
2 changed files with 24 additions and 22 deletions

View file

@ -164,22 +164,24 @@ pub static CONFIG: LazyStatic<ConfigData> = LazyStatic::new(|| {
///
/// Ver [`Cómo añadir ajustes de configuración`](config/index.html#cómo-añadir-ajustes-de-configuración).
macro_rules! pub_config {
( $S:ident: $t:ty $(, $k:literal => $v:literal)*$(,)* ) => { $crate::doc_comment! {
( $SETTINGS:ident: $Settings:ty $(, $key:literal => $value:literal)*$(,)* ) => {
$crate::doc_comment! {
concat!(
"Declara y asigna los valores predefinidos para los ajustes de configuración ",
"asociados a la estructura [`", stringify!($t), "`]."
"asociados a la estructura [`", stringify!($Settings), "`]."
),
pub static $S: $crate::LazyStatic<$t> = $crate::LazyStatic::new(|| {
pub static $SETTINGS: $crate::LazyStatic<$Settings> = $crate::LazyStatic::new(|| {
let mut settings = $crate::config::CONFIG.clone();
$(
settings.set_default($k, $v).unwrap();
settings.set_default($key, $value).unwrap();
)*
match settings.try_into() {
Ok(s) => s,
Err(e) => panic!("Error parsing settings: {}", e),
}
});
}};
}
};
}
#[derive(Debug, Deserialize)]

View file

@ -73,9 +73,9 @@ pub fn component_mut<C: 'static>(component: &mut dyn ComponentTrait) -> &mut C {
#[macro_export]
macro_rules! hook_before_render_component {
( $ACTION_HANDLER:ident, $Component:ty ) => {
( $ACTION_HANDLE:ident, $Component:ty ) => {
paste::paste! {
$crate::pub_handle!($ACTION_HANDLER);
$crate::pub_handle!($ACTION_HANDLE);
type Action = fn(&$Component, &mut PageContext);
@ -93,7 +93,7 @@ macro_rules! hook_before_render_component {
}
fn handle(&self) -> Handle {
$ACTION_HANDLER
$ACTION_HANDLE
}
fn weight(&self) -> isize {
@ -127,9 +127,9 @@ macro_rules! hook_before_render_component {
#[inline(always)]
fn before_render_inline(component: &mut $Component, context: &mut PageContext) {
run_actions(
$ACTION_HANDLER,
|action| action_ref::<[< BeforeRender $Component >]>(&**action).run(component, context)
run_actions($ACTION_HANDLE, |action|
action_ref::<[< BeforeRender $Component >]>(&**action)
.run(component, context)
);
}
}