fix: enhance global key validation and update template parameters

This commit is contained in:
Relism
2026-04-29 10:31:14 +02:00
parent 0e2dad23e5
commit f310646868
6 changed files with 26 additions and 30 deletions
@@ -38,7 +38,7 @@ class JteRuntimeTest {
}
@Test
void render_rejectsReservedGlobalKeyInLocalModel() {
void render_rejectsConflictingLocalKey() {
JteRuntime runtime = new JteRuntime(
JteSettings.builder().templateRoot("/templates").developmentMode(true).build(),
List.of(new GlobalValue("appName", req -> "Flash"))
@@ -48,12 +48,12 @@ class JteRuntimeTest {
runtime.render(new JteHandler() {
@Override
public ViewModel render(Request req) {
return ViewModel.of("global", "bad");
return ViewModel.of("appName", "override"); // collide con global
}
}, new JteTarget("pages/home.jte", ContentType.TEXT_HTML), null, new Response(200, ContentType.JSON))
);
assertTrue(ex.getMessage().contains("reserved"));
assertTrue(ex.getMessage().contains("appName"));
}
@Test
@@ -1,10 +1,9 @@
@import dev.relism.flash.ext.view.jte.model.HomePage
@import java.util.Map
@param HomePage page
@param String build
@param Map<String, Object> global
@param String appName
<h1>${page.title()}</h1>
<p>${page.author()}</p>
<small>${build}</small>
<small>${(String) global.get("appName")}</small>
<small>${appName}</small>