🐛 (locale): Corrige escapado de L10n::using()

`L10n::using()` insertaba el texto de `L10n::n()` sin escapar,
tratándolo igual que una traducción de confianza (`l()`/`t()`); ahora se
escapa como cualquier otro valor interpolado con `html!`.

Además, `using()` no debe usarse en valores de atributo. Su marcado de
confianza para `l()`/`t()` podría romper el delimitador si la traducción
contuviera una comilla. Se sustituye por `lookup()`
This commit is contained in:
Manuel Cillero 2026-08-12 14:28:47 +02:00
parent 6bea4a5793
commit 3198b74399
13 changed files with 96 additions and 26 deletions

View file

@ -5,9 +5,8 @@ use crate::prelude::*;
/// # Ejemplo
///
/// ```rust,no_run
/// use pagetop::prelude::*;
///
/// let badge = Badge::new().with_label(L10n::n("Admin"));
/// # use pagetop::prelude::*;
/// let badge = Badge::labeled(L10n::n("Admin"));
/// ```
#[derive(AutoDefault, Clone, Debug, Getters)]
pub struct Badge {
@ -41,6 +40,14 @@ impl Component for Badge {
}
impl Badge {
/// Crea un badge a partir de la etiqueta indicada.
pub fn labeled(label: L10n) -> Self {
Self {
label,
..Default::default()
}
}
// **< Badge BUILDER >**************************************************************************
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
@ -50,7 +57,7 @@ impl Badge {
self
}
/// Modifica identificador, clases CSS o atributos HTML del componente.
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
#[builder_fn]
pub fn with_prop(mut self, op: PropsOp) -> Self {
self.props.alter_prop(op);

View file

@ -123,7 +123,7 @@ impl Component for Checkbox {
@if *self.required() {
span
class="form-required"
title=(L10n::l("field_required").using(cx))
title=[L10n::l("field_required").lookup(cx)]
{
"*"
}

View file

@ -238,7 +238,7 @@ impl Component for Field {
@if *self.required() {
span
class="form-required"
title=(L10n::l("field_required").using(cx))
title=[L10n::l("field_required").lookup(cx)]
{
"*"
}

View file

@ -89,7 +89,7 @@ impl Component for Number {
@if *self.required() {
span
class="form-required"
title=(L10n::l("field_required").using(cx))
title=[L10n::l("field_required").lookup(cx)]
{
"*"
}

View file

@ -150,7 +150,7 @@ impl Component for Field {
@if *self.required() {
span
class="form-required"
title=(L10n::l("field_required").using(cx))
title=[L10n::l("field_required").lookup(cx)]
{
"*"
}

View file

@ -246,7 +246,7 @@ impl Component for Field {
@if *self.required() {
span
class="form-required"
title=(L10n::l("field_required").using(cx))
title=[L10n::l("field_required").lookup(cx)]
{
"*"
}
@ -277,7 +277,7 @@ impl Component for Field {
}
Entry::Group(group) => {
optgroup
label=(group.label().using(cx))
label=[group.label().lookup(cx)]
disabled[*group.disabled()]
{
@for opt in group.items() {

View file

@ -99,7 +99,7 @@ impl Component for Textarea {
@if *self.required() {
span
class="form-required"
title=(L10n::l("field_required").using(cx))
title=[L10n::l("field_required").lookup(cx)]
{
"*"
}