Files
j2html/j2html-website/src/main/java/app/views/pages/IndexView.java
Scott Embler 94c82398ad Maven multi module support (#222)
* Restructuring to a Maven multi-module project.

- Renamed directories to match artifact ids.
- Added parent POM.
- Added developers to parent POM.
- Added dependency management and plugin management.  No expectation that the build or release process is fully functional.
- Extracted versions into properties like other projects.

* Fixed file paths for workflow and documentation.

- Added junit to j2html-codegen module.

* Temporarily setting packaging for j2html-codegen to pom, to allow workflow to complete.

* Removed copied configuration of maven-jar-plugin from parent POM.

* Integrating code generation into the main build process.

- j2html-codegen is now supplying a Maven plugin that can read a model file and generate corresponding attribute and tag classes as part of the project build.
- j2html classes that would conflict with the generated classes have been removed.

* Targeting LTS versions only.

- JDK 9 & 10 support ended  in 2018
2022-12-26 09:51:00 -05:00

65 lines
3.4 KiB
Java

package app.views.pages;
import app.views.MainView;
import static app.views.Partials.codeSnippet;
import static j2html.TagCreator.a;
import static j2html.TagCreator.attrs;
import static j2html.TagCreator.fileAsEscapedString;
import static j2html.TagCreator.h2;
import static j2html.TagCreator.h3;
import static j2html.TagCreator.li;
import static j2html.TagCreator.p;
import static j2html.TagCreator.section;
import static j2html.TagCreator.text;
import static j2html.TagCreator.ul;
public class IndexView {
public static String render() {
return MainView.render(
"Fast and fluent Java HTML5 builder",
"Fast and fluent Java HTML5 builder",
section(attrs("#index"),
h2("Getting started with j2html"),
p("Import TagCreator to get started. j2html's syntax is fluent and closely matched to HTML:"),
codeSnippet("java", fileAsEscapedString("/codeExamples/minimal.java")),
p("The Java code above becomes the HTML below:"),
codeSnippet("markup", fileAsEscapedString("/codeExamples/minimal.html")),
p(
text("Check out some more "),
a("examples").withHref("/examples.html"),
text(".")
),
h2("Intended use"),
h3("Consider using j2html if:"),
ul(
li("You love type safety. You love catching errors at compile time instead of waiting for some poor user to notice that something is wrong"),
li("You like to dynamically reuse your view code"),
li(
text("You think template engines are too slow. This index page was rendered 100 000 times in less than a second on an i5-4670. That's about a thousand times faster than Apache '"),
a("Velocity").withHref("http://velocity.apache.org/").withTarget("_blank"),
text("' (hah!)")
)
),
h3("Be careful about using j2html if:"),
ul(
li("You don't know Java and HTML well"),
li("You're creating a classic \"website\" that has a lot of static HTML (if it's all generated then it's fine)"),
li("Your application has a lot of text and you don't use language files / a database (string concatenation would get very annoying)"),
li("You use a CSS framework which relies on a lot of copy pasting HTML from docs. You'll have to translate these snippets to j2html")
),
h2("Why did you make this library?"),
p(
"First: j2html is a Java HTML builder. It's not a template engine, and it doesn't want to compete with template engines. "
+ "We were looking for a good way to create HTML for a complex login solution which had many different forms "
+ "(with different configurations, depending on user state and user actions, etc.), but very little actual HTML per page. "
+ "The result was j2html. We decided to release the Java HTML builder we made, since it seems better "
+ "than all the other Java HTML builders we found while researching the subject. Hopefully someone will find it useful!"
)
)
);
}
}