Skip to content

Commit

Permalink
fix templates
Browse files Browse the repository at this point in the history
  • Loading branch information
NastasiyaT committed Oct 13, 2023
1 parent 6a27da0 commit f0e94ad
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 7 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package gg.jte.generated.ondemand;
public final class JtemainpageGenerated {
public static final String JTE_NAME = "mainpage.jte";
public static final int[] JTE_LINE_INFO = {0,0,0,0,0,2,2,4,4,4};
public static void render(gg.jte.html.HtmlTemplateOutput jteOutput, gg.jte.html.HtmlInterceptor jteHtmlInterceptor) {
gg.jte.generated.ondemand.layout.JtepageGenerated.render(jteOutput, jteHtmlInterceptor, new gg.jte.html.HtmlContent() {
public void writeTo(gg.jte.html.HtmlTemplateOutput jteOutput) {
jteOutput.writeContent("\n <h1 style=\"text-align: center;\">Hello World</h1>\n ");
}
});
}
public static void renderMap(gg.jte.html.HtmlTemplateOutput jteOutput, gg.jte.html.HtmlInterceptor jteHtmlInterceptor, java.util.Map<String, Object> params) {
render(jteOutput, jteHtmlInterceptor);
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package gg.jte.generated.ondemand.layout;
import gg.jte.Content;
import hexlet.code.util.NamedRoutes;
public final class JtepageGenerated {
public static final String JTE_NAME = "layout/page.jte";
public static final int[] JTE_LINE_INFO = {0,0,1,2,2,2,16,16,16,16,16,16,16,16,16,19,19,19,24};
public static void render(gg.jte.html.HtmlTemplateOutput jteOutput, gg.jte.html.HtmlInterceptor jteHtmlInterceptor, Content content) {
jteOutput.writeContent("\n<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>WebApp</title>\n <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css\" rel=\"stylesheet\"\n integrity=\"sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN\" crossorigin=\"anonymous\">\n</head>\n<body>\n<header>\n <nav>\n <a");
if (gg.jte.runtime.TemplateUtils.isAttributeRendered(NamedRoutes.rootPath())) {
jteOutput.writeContent(" href=\"");
jteOutput.setContext("a", "href");
jteOutput.writeUserContent(NamedRoutes.rootPath());
jteOutput.setContext("a", null);
jteOutput.writeContent("\"");
}
jteOutput.writeContent(">Main Page</a>\n </nav>\n</header>\n");
jteOutput.setContext("body", null);
jteOutput.writeUserContent(content);
jteOutput.writeContent("\n<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js\"\n integrity=\"sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL\"\n crossorigin=\"anonymous\"></script>\n</body>\n</html>");
}
public static void renderMap(gg.jte.html.HtmlTemplateOutput jteOutput, gg.jte.html.HtmlInterceptor jteHtmlInterceptor, java.util.Map<String, Object> params) {
Content content = (Content)params.get("content");
render(jteOutput, jteHtmlInterceptor, content);
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/hexlet/code/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ private static int getPort() {
public static Javalin getApp() throws IOException, SQLException {

var hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName(org.postgresql.Driver.class.getName());
hikariConfig.setJdbcUrl(getDatabaseUrl());

var dataSource = new HikariDataSource(hikariConfig);
Expand All @@ -74,7 +73,7 @@ public static Javalin getApp() throws IOException, SQLException {

app.before(ctx -> ctx.contentType("text/html; charset=utf-8"));

app.get(NamedRoutes.rootPath(), ctx -> ctx.render("templates/mainpage.jte"));
app.get(NamedRoutes.rootPath(), ctx -> ctx.render("mainpage.jte"));

return app;
}
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/jte/templates/mainpage.jte

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions app/src/main/resources/templates/mainpage.jte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@template.layout.page(
content = @`
<h1 style="text-align: center;">Hello World</h1>
`
)

0 comments on commit f0e94ad

Please sign in to comment.