Compare commits
101 Commits
j2html-0.7
...
j2html-1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc3bb29b6a | ||
|
|
ef5777e54a | ||
|
|
cfc1489399 | ||
|
|
8112dad1bb | ||
|
|
235dec78ed | ||
|
|
6316dd2262 | ||
|
|
5667d7c68d | ||
|
|
13911d5f57 | ||
|
|
0bc6e274db | ||
|
|
325afd463c | ||
|
|
f331eb9eb3 | ||
|
|
d37dc1cac6 | ||
|
|
dab61bd662 | ||
|
|
d559f05903 | ||
|
|
97a8f34572 | ||
|
|
6305e364ca | ||
|
|
28ba518b12 | ||
|
|
5f04cde97c | ||
|
|
b00ba50133 | ||
|
|
e09918da12 | ||
|
|
55b74e81aa | ||
|
|
75deeff13d | ||
|
|
3aa05aa540 | ||
|
|
fb24d1eabf | ||
|
|
458f3baf98 | ||
|
|
a661f37575 | ||
|
|
26796cd30d | ||
|
|
75dc60c415 | ||
|
|
99b98f9b09 | ||
|
|
8d4756bab0 | ||
|
|
2c1f337348 | ||
|
|
d437e1affd | ||
|
|
4fdcc3c213 | ||
|
|
ba3261b210 | ||
|
|
ee0100d1a7 | ||
|
|
9ec3088d82 | ||
|
|
8052cdaff1 | ||
|
|
34b2410830 | ||
|
|
75d361fa20 | ||
|
|
3e91da0640 | ||
|
|
d1613b0570 | ||
|
|
a841271ba4 | ||
|
|
9272438940 | ||
|
|
3d43eb159f | ||
|
|
30bfe4ea7f | ||
|
|
7409772c20 | ||
|
|
29e16df057 | ||
|
|
6903bcbe4d | ||
|
|
56b830782f | ||
|
|
10a400ac28 | ||
|
|
e0b0425da4 | ||
|
|
f44d62d93a | ||
|
|
652b6921c7 | ||
|
|
d7e56686d1 | ||
|
|
cc289b8430 | ||
|
|
85d0ab023c | ||
|
|
0b3ca28cf3 | ||
|
|
45a7c32d88 | ||
|
|
733199cd15 | ||
|
|
df1e4da96d | ||
|
|
05dcf6d679 | ||
|
|
b5d7f5fe18 | ||
|
|
872baeeeea | ||
|
|
fcc42cfd8f | ||
|
|
db8d968f7e | ||
|
|
673a19faaa | ||
|
|
96020f8396 | ||
|
|
91c3f42696 | ||
|
|
0efd3c6f0c | ||
|
|
b73c5d0c14 | ||
|
|
977c31dad5 | ||
|
|
0c1cb2be10 | ||
|
|
d09eb8597c | ||
|
|
b8a3882529 | ||
|
|
b366207e30 | ||
|
|
3821671a65 | ||
|
|
66fff8db69 | ||
|
|
b11af765fa | ||
|
|
d331789074 | ||
|
|
314de2459a | ||
|
|
2beb4e903e | ||
|
|
d29da958e1 | ||
|
|
595d658a15 | ||
|
|
dd4a025ad0 | ||
|
|
3c42c7d4f4 | ||
|
|
871405c414 | ||
|
|
e7588aeb6a | ||
|
|
074aae4609 | ||
|
|
66479f52c5 | ||
|
|
a5e79b536d | ||
|
|
79e062355e | ||
|
|
947f12d5a1 | ||
|
|
a46ba46bda | ||
|
|
41da131bbc | ||
|
|
9428bf7397 | ||
|
|
67e1c887b8 | ||
|
|
bdd8dcbd2c | ||
|
|
b9d1f3a74d | ||
|
|
530565c9df | ||
|
|
30d1331c28 | ||
|
|
58b2444ed4 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -93,4 +93,9 @@ pom.xml.versionsBackup
|
|||||||
pom.xml.next
|
pom.xml.next
|
||||||
release.properties
|
release.properties
|
||||||
dependency-reduced-pom.xml
|
dependency-reduced-pom.xml
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
buildNumber.properties
|
buildNumber.properties
|
||||||
|
|||||||
8
.travis.yml
Normal file
8
.travis.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
language: java
|
||||||
|
jdk:
|
||||||
|
- oraclejdk8
|
||||||
|
sudo: false
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- oracle-java8-installer
|
||||||
12
README.md
12
README.md
@@ -1,7 +1,11 @@
|
|||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
# j2html
|
# j2html
|
||||||
Java to HTML generator. Enjoy typesafe HTML generation.
|
Java to HTML generator. Enjoy typesafe HTML generation.
|
||||||
|
|
||||||
The project webpage is [j2html.com](http://j2html.com)
|
The project webpage is [j2html.com](http://j2html.com).
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
### Add the maven dependency
|
### Add the maven dependency
|
||||||
@@ -9,9 +13,13 @@ The project webpage is [j2html.com](http://j2html.com)
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.j2html</groupId>
|
<groupId>com.j2html</groupId>
|
||||||
<artifactId>j2html</artifactId>
|
<artifactId>j2html</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
### OR the gradle dependency
|
||||||
|
```
|
||||||
|
compile 'com.j2html:j2html:1.0.0'
|
||||||
|
```
|
||||||
|
|
||||||
### Import TagCreator and start building HTML
|
### Import TagCreator and start building HTML
|
||||||
```java
|
```java
|
||||||
|
|||||||
40
pom.xml
40
pom.xml
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<groupId>com.j2html</groupId>
|
<groupId>com.j2html</groupId>
|
||||||
<artifactId>j2html</artifactId>
|
<artifactId>j2html</artifactId>
|
||||||
<version>0.7</version>
|
<version>1.1.0</version>
|
||||||
|
|
||||||
<name>j2html</name>
|
<name>j2html</name>
|
||||||
<description>Java to HTML builder with a fluent API</description>
|
<description>Java to HTML builder with a fluent API</description>
|
||||||
@@ -44,16 +44,19 @@
|
|||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.12</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
<artifactId>hamcrest-library</artifactId>
|
||||||
|
<version>1.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.4</version>
|
<version>3.0</version>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.javascript</groupId>
|
|
||||||
<artifactId>closure-compiler</artifactId>
|
|
||||||
<version>r2388</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@@ -61,13 +64,29 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.orfjackal.retrolambda</groupId>
|
||||||
|
<artifactId>retrolambda-maven-plugin</artifactId>
|
||||||
|
<version>2.5.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>process-main</goal>
|
||||||
|
<goal>process-test</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.3</version>
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
<optimize>true</optimize>
|
<optimize>true</optimize>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@@ -84,7 +103,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<rules>
|
<rules>
|
||||||
<requireJavaVersion>
|
<requireJavaVersion>
|
||||||
<version>[1.7,)</version>
|
<version>[1.8,)</version>
|
||||||
</requireJavaVersion>
|
</requireJavaVersion>
|
||||||
</rules>
|
</rules>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -99,7 +118,6 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|||||||
13
src/main/java/j2html/Config.java
Normal file
13
src/main/java/j2html/Config.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package j2html;
|
||||||
|
|
||||||
|
import j2html.utils.SimpleEscaper;
|
||||||
|
import j2html.utils.TextEscaper;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
|
||||||
|
private Config() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TextEscaper textEscaper = new SimpleEscaper();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,178 +1,842 @@
|
|||||||
package j2html;
|
package j2html;
|
||||||
|
|
||||||
import j2html.tags.*;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import j2html.attributes.Attr;
|
||||||
|
import j2html.tags.ContainerTag;
|
||||||
|
import j2html.tags.DomContent;
|
||||||
|
import j2html.tags.DomContentJoiner;
|
||||||
|
import j2html.tags.EmptyTag;
|
||||||
|
import j2html.tags.InlineStaticResource;
|
||||||
|
import j2html.tags.Text;
|
||||||
|
import j2html.tags.UnescapedText;
|
||||||
|
|
||||||
public class TagCreator {
|
public class TagCreator {
|
||||||
|
|
||||||
|
private TagCreator() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic if-expression to do if'ing inside method calls
|
||||||
|
*
|
||||||
|
* @param <T> The derived generic parameter type
|
||||||
|
* @param condition the condition to if-on
|
||||||
|
* @param ifValue the value to return if condition is true
|
||||||
|
* @return value if condition is true, null otherwise
|
||||||
|
*/
|
||||||
|
public static <T> T iff(boolean condition, T ifValue) {
|
||||||
|
return condition ? ifValue : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like {@link j2html.TagCreator#iff}, but returns else-value instead of null
|
||||||
|
*/
|
||||||
|
public static <T> T iffElse(boolean condition, T ifValue, T elseValue) {
|
||||||
|
return condition ? ifValue : elseValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a Attr.ShortForm object with either id, classes or both,
|
||||||
|
* obtained from parsing the input string using css selector syntax
|
||||||
|
*
|
||||||
|
* @param attrs the string with shortform attributes, only id and class is supported
|
||||||
|
* @return a Attr.ShortForm object
|
||||||
|
*/
|
||||||
|
public static Attr.ShortForm attrs(String attrs) {
|
||||||
|
return Attr.shortFormFromAttrsString(attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the HTML created by concatenating the input elements,
|
||||||
|
* separated by space, in encounter order.
|
||||||
|
* Also removes spaces before periods and commas.
|
||||||
|
*
|
||||||
|
* @param stringOrDomObjects the elements to join
|
||||||
|
* @return joined elements as HTML
|
||||||
|
*/
|
||||||
|
public static UnescapedText join(Object... stringOrDomObjects) {
|
||||||
|
return DomContentJoiner.join(" ", true, stringOrDomObjects);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a DomContent object containing HTML using a mapping function on a collection
|
||||||
|
* Intended usage: {@literal each(numbers, n -> li(n.toString()))}
|
||||||
|
*
|
||||||
|
* @param <T> The derived generic parameter type
|
||||||
|
* @param collection the collection to iterate over, ex: a list of values "1, 2, 3"
|
||||||
|
* @param mapper the mapping function, ex: {@literal "n -> li(n.toString())"}
|
||||||
|
* @return rawHtml containing mapped data {@literal (ex. docs: <li>1</li><li>2</li><li>3</li>)}
|
||||||
|
*/
|
||||||
|
public static <T> DomContent each(Collection<T> collection, Function<? super T, DomContent> mapper) {
|
||||||
|
return rawHtml(collection.stream().map(mapper.andThen(DomContent::render)).collect(Collectors.joining()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters a collection to a list, to be used with {@link j2html.TagCreator#each}
|
||||||
|
* Intended usage: {@literal each(filter(numbers, n -> n % 2 == 0), n -> li(n.toString()))}
|
||||||
|
*
|
||||||
|
* @param <T> The derived generic parameter type
|
||||||
|
* @param collection the collection to filter, ex: a list of values "1, 2, 3"
|
||||||
|
* @param filter the filter predicate, {@literal ex: "n -> n % 2 == 0"}
|
||||||
|
* @return the filtered collection as a list (ex. docs: 2)
|
||||||
|
*/
|
||||||
|
public static <T> List<T> filter(Collection<T> collection, Predicate<? super T> filter) {
|
||||||
|
return collection.stream().filter(filter).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a String in an UnescapedText element
|
||||||
|
*
|
||||||
|
* @param html the input html
|
||||||
|
* @return the input html wrapped in an UnescapedText element
|
||||||
|
*/
|
||||||
|
public static UnescapedText rawHtml(String html) {
|
||||||
|
return new UnescapedText(html);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a String in a Text element (does html-escaping)
|
||||||
|
*
|
||||||
|
* @param text the input string
|
||||||
|
* @return the input string, html-escaped
|
||||||
|
*/
|
||||||
|
public static Text text(String text) {
|
||||||
|
return new Text(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a complete html document string
|
||||||
|
*
|
||||||
|
* @param htmlTag the html content of a website
|
||||||
|
* @return document declaration and rendered html content
|
||||||
|
*/
|
||||||
|
public static String document(ContainerTag htmlTag) {
|
||||||
|
if (htmlTag.getTagName().equals("html")) {
|
||||||
|
return new EmptyTag("!DOCTYPE html").render() + htmlTag.render();
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Only HTML-tag can follow document declaration");
|
||||||
|
}
|
||||||
|
|
||||||
//Special tags
|
//Special tags
|
||||||
public static ContainerTag tag(String tagName) { return new ContainerTag(tagName); }
|
public static ContainerTag tag(String tagName) { return new ContainerTag(tagName); }
|
||||||
public static EmptyTag emptyTag(String tagName) { return new EmptyTag(tagName); }
|
public static EmptyTag emptyTag(String tagName) { return new EmptyTag(tagName); }
|
||||||
|
|
||||||
public static Text text(String text) { return new Text(text); }
|
public static Text fileAsEscapedString(String path) { return text(InlineStaticResource.getFileAsString(path)); }
|
||||||
public static UnescapedText unsafeHtml(String html) { return new UnescapedText(html); }
|
public static UnescapedText fileAsString(String path) { return rawHtml(InlineStaticResource.getFileAsString(path)); }
|
||||||
|
|
||||||
public static Tag styleWithInlineFile(String path) { return InlineStaticResource.get(path, InlineStaticResource.TargetFormat.CSS); }
|
public static ContainerTag styleWithInlineFile(String path) { return InlineStaticResource.get(path, InlineStaticResource.TargetFormat.CSS); }
|
||||||
public static Tag scriptWithInlineFile(String path) { return InlineStaticResource.get(path, InlineStaticResource.TargetFormat.JS); }
|
public static ContainerTag scriptWithInlineFile(String path) { return InlineStaticResource.get(path, InlineStaticResource.TargetFormat.JS); }
|
||||||
public static Tag styleWithInlineFile_min(String path) { return InlineStaticResource.get(path, InlineStaticResource.TargetFormat.CSS_MIN); }
|
public static ContainerTag styleWithInlineFile_min(String path) { return InlineStaticResource.get(path, InlineStaticResource.TargetFormat.CSS_MIN); }
|
||||||
public static Tag scriptWithInlineFile_min(String path) { return InlineStaticResource.get(path, InlineStaticResource.TargetFormat.JS_MIN); }
|
public static ContainerTag scriptWithInlineFile_min(String path) { return InlineStaticResource.get(path, InlineStaticResource.TargetFormat.JS_MIN); }
|
||||||
|
|
||||||
public static UnescapedText fileAsString(String path) { return new UnescapedText(InlineStaticResource.getFileAsString(path)); }
|
|
||||||
public static Text fileAsEscapedString(String path) { return new Text(InlineStaticResource.getFileAsString(path)); }
|
|
||||||
|
|
||||||
|
|
||||||
//EmptyTags
|
|
||||||
public static EmptyTag area() { return new EmptyTag("area"); }
|
|
||||||
public static EmptyTag base() { return new EmptyTag("base"); }
|
|
||||||
public static EmptyTag br() { return new EmptyTag("br"); }
|
|
||||||
public static EmptyTag col() { return new EmptyTag("col"); }
|
|
||||||
public static EmptyTag document() { return new EmptyTag("!DOCTYPE html"); }
|
public static EmptyTag document() { return new EmptyTag("!DOCTYPE html"); }
|
||||||
|
|
||||||
|
// EmptyTags, generated in class j2html.tags.TagCreatorCodeGenerator
|
||||||
|
public static EmptyTag area() { return new EmptyTag("area"); }
|
||||||
|
public static EmptyTag area(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("area"), shortAttr); }
|
||||||
|
|
||||||
|
public static EmptyTag base() { return new EmptyTag("base"); }
|
||||||
|
public static EmptyTag base(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("base"), shortAttr); }
|
||||||
|
|
||||||
|
public static EmptyTag br() { return new EmptyTag("br"); }
|
||||||
|
public static EmptyTag br(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("br"), shortAttr); }
|
||||||
|
|
||||||
|
public static EmptyTag col() { return new EmptyTag("col"); }
|
||||||
|
public static EmptyTag col(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("col"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag embed() { return new EmptyTag("embed"); }
|
public static EmptyTag embed() { return new EmptyTag("embed"); }
|
||||||
|
public static EmptyTag embed(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("embed"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag hr() { return new EmptyTag("hr"); }
|
public static EmptyTag hr() { return new EmptyTag("hr"); }
|
||||||
|
public static EmptyTag hr(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("hr"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag img() { return new EmptyTag("img"); }
|
public static EmptyTag img() { return new EmptyTag("img"); }
|
||||||
|
public static EmptyTag img(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("img"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag input() { return new EmptyTag("input"); }
|
public static EmptyTag input() { return new EmptyTag("input"); }
|
||||||
|
public static EmptyTag input(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("input"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag keygen() { return new EmptyTag("keygen"); }
|
public static EmptyTag keygen() { return new EmptyTag("keygen"); }
|
||||||
|
public static EmptyTag keygen(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("keygen"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag link() { return new EmptyTag("link"); }
|
public static EmptyTag link() { return new EmptyTag("link"); }
|
||||||
|
public static EmptyTag link(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("link"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag meta() { return new EmptyTag("meta"); }
|
public static EmptyTag meta() { return new EmptyTag("meta"); }
|
||||||
|
public static EmptyTag meta(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("meta"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag param() { return new EmptyTag("param"); }
|
public static EmptyTag param() { return new EmptyTag("param"); }
|
||||||
|
public static EmptyTag param(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("param"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag source() { return new EmptyTag("source"); }
|
public static EmptyTag source() { return new EmptyTag("source"); }
|
||||||
|
public static EmptyTag source(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("source"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag track() { return new EmptyTag("track"); }
|
public static EmptyTag track() { return new EmptyTag("track"); }
|
||||||
|
public static EmptyTag track(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("track"), shortAttr); }
|
||||||
|
|
||||||
public static EmptyTag wbr() { return new EmptyTag("wbr"); }
|
public static EmptyTag wbr() { return new EmptyTag("wbr"); }
|
||||||
|
public static EmptyTag wbr(Attr.ShortForm shortAttr) { return Attr.addTo(new EmptyTag("wbr"), shortAttr); }
|
||||||
|
|
||||||
|
// ContainerTags, generated in class j2html.tags.TagCreatorCodeGenerator
|
||||||
//ContainerTags
|
|
||||||
public static ContainerTag a() { return new ContainerTag("a"); }
|
public static ContainerTag a() { return new ContainerTag("a"); }
|
||||||
public static ContainerTag a(String text) { return new ContainerTag("a").withText(text); }
|
public static ContainerTag a(String text) { return new ContainerTag("a").withText(text); }
|
||||||
|
public static ContainerTag a(DomContent... dc) { return new ContainerTag("a").with(dc); }
|
||||||
|
public static ContainerTag a(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("a"), shortAttr); }
|
||||||
|
public static ContainerTag a(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("a").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag a(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("a").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag abbr() { return new ContainerTag("abbr"); }
|
public static ContainerTag abbr() { return new ContainerTag("abbr"); }
|
||||||
|
public static ContainerTag abbr(String text) { return new ContainerTag("abbr").withText(text); }
|
||||||
|
public static ContainerTag abbr(DomContent... dc) { return new ContainerTag("abbr").with(dc); }
|
||||||
|
public static ContainerTag abbr(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("abbr"), shortAttr); }
|
||||||
|
public static ContainerTag abbr(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("abbr").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag abbr(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("abbr").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag address() { return new ContainerTag("address"); }
|
public static ContainerTag address() { return new ContainerTag("address"); }
|
||||||
|
public static ContainerTag address(String text) { return new ContainerTag("address").withText(text); }
|
||||||
|
public static ContainerTag address(DomContent... dc) { return new ContainerTag("address").with(dc); }
|
||||||
|
public static ContainerTag address(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("address"), shortAttr); }
|
||||||
|
public static ContainerTag address(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("address").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag address(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("address").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag article() { return new ContainerTag("article"); }
|
public static ContainerTag article() { return new ContainerTag("article"); }
|
||||||
|
public static ContainerTag article(String text) { return new ContainerTag("article").withText(text); }
|
||||||
|
public static ContainerTag article(DomContent... dc) { return new ContainerTag("article").with(dc); }
|
||||||
|
public static ContainerTag article(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("article"), shortAttr); }
|
||||||
|
public static ContainerTag article(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("article").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag article(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("article").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag aside() { return new ContainerTag("aside"); }
|
public static ContainerTag aside() { return new ContainerTag("aside"); }
|
||||||
|
public static ContainerTag aside(String text) { return new ContainerTag("aside").withText(text); }
|
||||||
|
public static ContainerTag aside(DomContent... dc) { return new ContainerTag("aside").with(dc); }
|
||||||
|
public static ContainerTag aside(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("aside"), shortAttr); }
|
||||||
|
public static ContainerTag aside(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("aside").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag aside(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("aside").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag audio() { return new ContainerTag("audio"); }
|
public static ContainerTag audio() { return new ContainerTag("audio"); }
|
||||||
|
public static ContainerTag audio(String text) { return new ContainerTag("audio").withText(text); }
|
||||||
|
public static ContainerTag audio(DomContent... dc) { return new ContainerTag("audio").with(dc); }
|
||||||
|
public static ContainerTag audio(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("audio"), shortAttr); }
|
||||||
|
public static ContainerTag audio(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("audio").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag audio(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("audio").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag b() { return new ContainerTag("b"); }
|
public static ContainerTag b() { return new ContainerTag("b"); }
|
||||||
public static ContainerTag b(String text) { return new ContainerTag("b").withText(text); }
|
public static ContainerTag b(String text) { return new ContainerTag("b").withText(text); }
|
||||||
|
public static ContainerTag b(DomContent... dc) { return new ContainerTag("b").with(dc); }
|
||||||
|
public static ContainerTag b(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("b"), shortAttr); }
|
||||||
|
public static ContainerTag b(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("b").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag b(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("b").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag bdi() { return new ContainerTag("bdi"); }
|
public static ContainerTag bdi() { return new ContainerTag("bdi"); }
|
||||||
public static ContainerTag bdi(String text) { return new ContainerTag("bdi").withText(text); }
|
public static ContainerTag bdi(String text) { return new ContainerTag("bdi").withText(text); }
|
||||||
|
public static ContainerTag bdi(DomContent... dc) { return new ContainerTag("bdi").with(dc); }
|
||||||
|
public static ContainerTag bdi(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("bdi"), shortAttr); }
|
||||||
|
public static ContainerTag bdi(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("bdi").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag bdi(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("bdi").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag bdo() { return new ContainerTag("bdo"); }
|
public static ContainerTag bdo() { return new ContainerTag("bdo"); }
|
||||||
public static ContainerTag bdo(String text) { return new ContainerTag("bdo").withText(text); }
|
public static ContainerTag bdo(String text) { return new ContainerTag("bdo").withText(text); }
|
||||||
|
public static ContainerTag bdo(DomContent... dc) { return new ContainerTag("bdo").with(dc); }
|
||||||
|
public static ContainerTag bdo(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("bdo"), shortAttr); }
|
||||||
|
public static ContainerTag bdo(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("bdo").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag bdo(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("bdo").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag blockquote() { return new ContainerTag("blockquote"); }
|
public static ContainerTag blockquote() { return new ContainerTag("blockquote"); }
|
||||||
public static ContainerTag blockquote(String text) { return new ContainerTag("blockquote").withText(text); }
|
public static ContainerTag blockquote(String text) { return new ContainerTag("blockquote").withText(text); }
|
||||||
|
public static ContainerTag blockquote(DomContent... dc) { return new ContainerTag("blockquote").with(dc); }
|
||||||
|
public static ContainerTag blockquote(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("blockquote"), shortAttr); }
|
||||||
|
public static ContainerTag blockquote(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("blockquote").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag blockquote(Attr.ShortForm shortAttr, DomContent... dc){ return Attr.addTo(new ContainerTag("blockquote").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag body() { return new ContainerTag("body"); }
|
public static ContainerTag body() { return new ContainerTag("body"); }
|
||||||
|
public static ContainerTag body(String text) { return new ContainerTag("body").withText(text); }
|
||||||
|
public static ContainerTag body(DomContent... dc) { return new ContainerTag("body").with(dc); }
|
||||||
|
public static ContainerTag body(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("body"), shortAttr); }
|
||||||
|
public static ContainerTag body(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("body").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag body(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("body").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag button() { return new ContainerTag("button"); }
|
public static ContainerTag button() { return new ContainerTag("button"); }
|
||||||
public static ContainerTag button(String text) { return new ContainerTag("button").withText(text); }
|
public static ContainerTag button(String text) { return new ContainerTag("button").withText(text); }
|
||||||
|
public static ContainerTag button(DomContent... dc) { return new ContainerTag("button").with(dc); }
|
||||||
|
public static ContainerTag button(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("button"), shortAttr); }
|
||||||
|
public static ContainerTag button(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("button").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag button(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("button").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag canvas() { return new ContainerTag("canvas"); }
|
public static ContainerTag canvas() { return new ContainerTag("canvas"); }
|
||||||
|
public static ContainerTag canvas(String text) { return new ContainerTag("canvas").withText(text); }
|
||||||
|
public static ContainerTag canvas(DomContent... dc) { return new ContainerTag("canvas").with(dc); }
|
||||||
|
public static ContainerTag canvas(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("canvas"), shortAttr); }
|
||||||
|
public static ContainerTag canvas(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("canvas").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag canvas(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("canvas").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag caption() { return new ContainerTag("caption"); }
|
public static ContainerTag caption() { return new ContainerTag("caption"); }
|
||||||
public static ContainerTag caption(String text) { return new ContainerTag("caption").withText(text); }
|
public static ContainerTag caption(String text) { return new ContainerTag("caption").withText(text); }
|
||||||
|
public static ContainerTag caption(DomContent... dc) { return new ContainerTag("caption").with(dc); }
|
||||||
|
public static ContainerTag caption(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("caption"), shortAttr); }
|
||||||
|
public static ContainerTag caption(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("caption").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag caption(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("caption").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag cite() { return new ContainerTag("cite"); }
|
public static ContainerTag cite() { return new ContainerTag("cite"); }
|
||||||
public static ContainerTag cite(String text) { return new ContainerTag("cite").withText(text); }
|
public static ContainerTag cite(String text) { return new ContainerTag("cite").withText(text); }
|
||||||
|
public static ContainerTag cite(DomContent... dc) { return new ContainerTag("cite").with(dc); }
|
||||||
|
public static ContainerTag cite(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("cite"), shortAttr); }
|
||||||
|
public static ContainerTag cite(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("cite").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag cite(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("cite").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag code() { return new ContainerTag("code"); }
|
public static ContainerTag code() { return new ContainerTag("code"); }
|
||||||
|
public static ContainerTag code(String text) { return new ContainerTag("code").withText(text); }
|
||||||
|
public static ContainerTag code(DomContent... dc) { return new ContainerTag("code").with(dc); }
|
||||||
|
public static ContainerTag code(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("code"), shortAttr); }
|
||||||
|
public static ContainerTag code(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("code").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag code(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("code").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag colgroup() { return new ContainerTag("colgroup"); }
|
public static ContainerTag colgroup() { return new ContainerTag("colgroup"); }
|
||||||
|
public static ContainerTag colgroup(String text) { return new ContainerTag("colgroup").withText(text); }
|
||||||
|
public static ContainerTag colgroup(DomContent... dc) { return new ContainerTag("colgroup").with(dc); }
|
||||||
|
public static ContainerTag colgroup(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("colgroup"), shortAttr); }
|
||||||
|
public static ContainerTag colgroup(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("colgroup").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag colgroup(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("colgroup").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag datalist() { return new ContainerTag("datalist"); }
|
public static ContainerTag datalist() { return new ContainerTag("datalist"); }
|
||||||
|
public static ContainerTag datalist(String text) { return new ContainerTag("datalist").withText(text); }
|
||||||
|
public static ContainerTag datalist(DomContent... dc) { return new ContainerTag("datalist").with(dc); }
|
||||||
|
public static ContainerTag datalist(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("datalist"), shortAttr); }
|
||||||
|
public static ContainerTag datalist(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("datalist").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag datalist(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("datalist").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag dd() { return new ContainerTag("dd"); }
|
public static ContainerTag dd() { return new ContainerTag("dd"); }
|
||||||
public static ContainerTag dd(String text) { return new ContainerTag("dd").withText(text); }
|
public static ContainerTag dd(String text) { return new ContainerTag("dd").withText(text); }
|
||||||
|
public static ContainerTag dd(DomContent... dc) { return new ContainerTag("dd").with(dc); }
|
||||||
|
public static ContainerTag dd(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("dd"), shortAttr); }
|
||||||
|
public static ContainerTag dd(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("dd").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag dd(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("dd").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag del() { return new ContainerTag("del"); }
|
public static ContainerTag del() { return new ContainerTag("del"); }
|
||||||
public static ContainerTag del(String text) { return new ContainerTag("del").withText(text); }
|
public static ContainerTag del(String text) { return new ContainerTag("del").withText(text); }
|
||||||
|
public static ContainerTag del(DomContent... dc) { return new ContainerTag("del").with(dc); }
|
||||||
|
public static ContainerTag del(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("del"), shortAttr); }
|
||||||
|
public static ContainerTag del(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("del").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag del(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("del").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag details() { return new ContainerTag("details"); }
|
public static ContainerTag details() { return new ContainerTag("details"); }
|
||||||
|
public static ContainerTag details(String text) { return new ContainerTag("details").withText(text); }
|
||||||
|
public static ContainerTag details(DomContent... dc) { return new ContainerTag("details").with(dc); }
|
||||||
|
public static ContainerTag details(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("details"), shortAttr); }
|
||||||
|
public static ContainerTag details(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("details").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag details(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("details").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag dfn() { return new ContainerTag("dfn"); }
|
public static ContainerTag dfn() { return new ContainerTag("dfn"); }
|
||||||
public static ContainerTag dfn(String text) { return new ContainerTag("dfn").withText(text); }
|
public static ContainerTag dfn(String text) { return new ContainerTag("dfn").withText(text); }
|
||||||
|
public static ContainerTag dfn(DomContent... dc) { return new ContainerTag("dfn").with(dc); }
|
||||||
|
public static ContainerTag dfn(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("dfn"), shortAttr); }
|
||||||
|
public static ContainerTag dfn(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("dfn").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag dfn(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("dfn").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag dialog() { return new ContainerTag("dialog"); }
|
public static ContainerTag dialog() { return new ContainerTag("dialog"); }
|
||||||
public static ContainerTag dialog(String text) { return new ContainerTag("dialog").withText(text); }
|
public static ContainerTag dialog(String text) { return new ContainerTag("dialog").withText(text); }
|
||||||
|
public static ContainerTag dialog(DomContent... dc) { return new ContainerTag("dialog").with(dc); }
|
||||||
|
public static ContainerTag dialog(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("dialog"), shortAttr); }
|
||||||
|
public static ContainerTag dialog(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("dialog").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag dialog(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("dialog").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag div() { return new ContainerTag("div"); }
|
public static ContainerTag div() { return new ContainerTag("div"); }
|
||||||
|
public static ContainerTag div(String text) { return new ContainerTag("div").withText(text); }
|
||||||
|
public static ContainerTag div(DomContent... dc) { return new ContainerTag("div").with(dc); }
|
||||||
|
public static ContainerTag div(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("div"), shortAttr); }
|
||||||
|
public static ContainerTag div(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("div").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag div(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("div").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag dl() { return new ContainerTag("dl"); }
|
public static ContainerTag dl() { return new ContainerTag("dl"); }
|
||||||
|
public static ContainerTag dl(String text) { return new ContainerTag("dl").withText(text); }
|
||||||
|
public static ContainerTag dl(DomContent... dc) { return new ContainerTag("dl").with(dc); }
|
||||||
|
public static ContainerTag dl(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("dl"), shortAttr); }
|
||||||
|
public static ContainerTag dl(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("dl").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag dl(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("dl").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag dt() { return new ContainerTag("dt"); }
|
public static ContainerTag dt() { return new ContainerTag("dt"); }
|
||||||
public static ContainerTag dt(String text) { return new ContainerTag("dt").withText(text); }
|
public static ContainerTag dt(String text) { return new ContainerTag("dt").withText(text); }
|
||||||
|
public static ContainerTag dt(DomContent... dc) { return new ContainerTag("dt").with(dc); }
|
||||||
|
public static ContainerTag dt(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("dt"), shortAttr); }
|
||||||
|
public static ContainerTag dt(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("dt").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag dt(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("dt").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag em() { return new ContainerTag("em"); }
|
public static ContainerTag em() { return new ContainerTag("em"); }
|
||||||
public static ContainerTag em(String text) { return new ContainerTag("em").withText(text); }
|
public static ContainerTag em(String text) { return new ContainerTag("em").withText(text); }
|
||||||
|
public static ContainerTag em(DomContent... dc) { return new ContainerTag("em").with(dc); }
|
||||||
|
public static ContainerTag em(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("em"), shortAttr); }
|
||||||
|
public static ContainerTag em(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("em").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag em(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("em").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag fieldset() { return new ContainerTag("fieldset"); }
|
public static ContainerTag fieldset() { return new ContainerTag("fieldset"); }
|
||||||
|
public static ContainerTag fieldset(String text) { return new ContainerTag("fieldset").withText(text); }
|
||||||
|
public static ContainerTag fieldset(DomContent... dc) { return new ContainerTag("fieldset").with(dc); }
|
||||||
|
public static ContainerTag fieldset(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("fieldset"), shortAttr); }
|
||||||
|
public static ContainerTag fieldset(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("fieldset").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag fieldset(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("fieldset").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag figcaption() { return new ContainerTag("figcaption"); }
|
public static ContainerTag figcaption() { return new ContainerTag("figcaption"); }
|
||||||
public static ContainerTag figcaption(String text) { return new ContainerTag("figcaption").withText(text); }
|
public static ContainerTag figcaption(String text) { return new ContainerTag("figcaption").withText(text); }
|
||||||
|
public static ContainerTag figcaption(DomContent... dc) { return new ContainerTag("figcaption").with(dc); }
|
||||||
|
public static ContainerTag figcaption(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("figcaption"), shortAttr); }
|
||||||
|
public static ContainerTag figcaption(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("figcaption").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag figcaption(Attr.ShortForm shortAttr, DomContent... dc){ return Attr.addTo(new ContainerTag("figcaption").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag figure() { return new ContainerTag("figure"); }
|
public static ContainerTag figure() { return new ContainerTag("figure"); }
|
||||||
|
public static ContainerTag figure(String text) { return new ContainerTag("figure").withText(text); }
|
||||||
|
public static ContainerTag figure(DomContent... dc) { return new ContainerTag("figure").with(dc); }
|
||||||
|
public static ContainerTag figure(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("figure"), shortAttr); }
|
||||||
|
public static ContainerTag figure(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("figure").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag figure(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("figure").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag footer() { return new ContainerTag("footer"); }
|
public static ContainerTag footer() { return new ContainerTag("footer"); }
|
||||||
|
public static ContainerTag footer(String text) { return new ContainerTag("footer").withText(text); }
|
||||||
|
public static ContainerTag footer(DomContent... dc) { return new ContainerTag("footer").with(dc); }
|
||||||
|
public static ContainerTag footer(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("footer"), shortAttr); }
|
||||||
|
public static ContainerTag footer(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("footer").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag footer(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("footer").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag form() { return new ContainerTag("form"); }
|
public static ContainerTag form() { return new ContainerTag("form"); }
|
||||||
|
public static ContainerTag form(String text) { return new ContainerTag("form").withText(text); }
|
||||||
|
public static ContainerTag form(DomContent... dc) { return new ContainerTag("form").with(dc); }
|
||||||
|
public static ContainerTag form(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("form"), shortAttr); }
|
||||||
|
public static ContainerTag form(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("form").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag form(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("form").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag h1() { return new ContainerTag("h1"); }
|
public static ContainerTag h1() { return new ContainerTag("h1"); }
|
||||||
public static ContainerTag h1(String text) { return new ContainerTag("h1").withText(text); }
|
public static ContainerTag h1(String text) { return new ContainerTag("h1").withText(text); }
|
||||||
|
public static ContainerTag h1(DomContent... dc) { return new ContainerTag("h1").with(dc); }
|
||||||
|
public static ContainerTag h1(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("h1"), shortAttr); }
|
||||||
|
public static ContainerTag h1(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("h1").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag h1(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("h1").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag h2() { return new ContainerTag("h2"); }
|
public static ContainerTag h2() { return new ContainerTag("h2"); }
|
||||||
public static ContainerTag h2(String text) { return new ContainerTag("h2").withText(text); }
|
public static ContainerTag h2(String text) { return new ContainerTag("h2").withText(text); }
|
||||||
|
public static ContainerTag h2(DomContent... dc) { return new ContainerTag("h2").with(dc); }
|
||||||
|
public static ContainerTag h2(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("h2"), shortAttr); }
|
||||||
|
public static ContainerTag h2(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("h2").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag h2(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("h2").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag h3() { return new ContainerTag("h3"); }
|
public static ContainerTag h3() { return new ContainerTag("h3"); }
|
||||||
public static ContainerTag h3(String text) { return new ContainerTag("h3").withText(text); }
|
public static ContainerTag h3(String text) { return new ContainerTag("h3").withText(text); }
|
||||||
|
public static ContainerTag h3(DomContent... dc) { return new ContainerTag("h3").with(dc); }
|
||||||
|
public static ContainerTag h3(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("h3"), shortAttr); }
|
||||||
|
public static ContainerTag h3(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("h3").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag h3(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("h3").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag h4() { return new ContainerTag("h4"); }
|
public static ContainerTag h4() { return new ContainerTag("h4"); }
|
||||||
public static ContainerTag h4(String text) { return new ContainerTag("h4").withText(text); }
|
public static ContainerTag h4(String text) { return new ContainerTag("h4").withText(text); }
|
||||||
|
public static ContainerTag h4(DomContent... dc) { return new ContainerTag("h4").with(dc); }
|
||||||
|
public static ContainerTag h4(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("h4"), shortAttr); }
|
||||||
|
public static ContainerTag h4(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("h4").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag h4(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("h4").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag h5() { return new ContainerTag("h5"); }
|
public static ContainerTag h5() { return new ContainerTag("h5"); }
|
||||||
public static ContainerTag h5(String text) { return new ContainerTag("h5").withText(text); }
|
public static ContainerTag h5(String text) { return new ContainerTag("h5").withText(text); }
|
||||||
|
public static ContainerTag h5(DomContent... dc) { return new ContainerTag("h5").with(dc); }
|
||||||
|
public static ContainerTag h5(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("h5"), shortAttr); }
|
||||||
|
public static ContainerTag h5(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("h5").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag h5(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("h5").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag h6() { return new ContainerTag("h6"); }
|
public static ContainerTag h6() { return new ContainerTag("h6"); }
|
||||||
public static ContainerTag h6(String text) { return new ContainerTag("h6").withText(text); }
|
public static ContainerTag h6(String text) { return new ContainerTag("h6").withText(text); }
|
||||||
|
public static ContainerTag h6(DomContent... dc) { return new ContainerTag("h6").with(dc); }
|
||||||
|
public static ContainerTag h6(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("h6"), shortAttr); }
|
||||||
|
public static ContainerTag h6(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("h6").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag h6(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("h6").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag head() { return new ContainerTag("head"); }
|
public static ContainerTag head() { return new ContainerTag("head"); }
|
||||||
|
public static ContainerTag head(String text) { return new ContainerTag("head").withText(text); }
|
||||||
|
public static ContainerTag head(DomContent... dc) { return new ContainerTag("head").with(dc); }
|
||||||
|
public static ContainerTag head(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("head"), shortAttr); }
|
||||||
|
public static ContainerTag head(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("head").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag head(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("head").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag header() { return new ContainerTag("header"); }
|
public static ContainerTag header() { return new ContainerTag("header"); }
|
||||||
|
public static ContainerTag header(String text) { return new ContainerTag("header").withText(text); }
|
||||||
|
public static ContainerTag header(DomContent... dc) { return new ContainerTag("header").with(dc); }
|
||||||
|
public static ContainerTag header(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("header"), shortAttr); }
|
||||||
|
public static ContainerTag header(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("header").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag header(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("header").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag html() { return new ContainerTag("html"); }
|
public static ContainerTag html() { return new ContainerTag("html"); }
|
||||||
|
public static ContainerTag html(String text) { return new ContainerTag("html").withText(text); }
|
||||||
|
public static ContainerTag html(DomContent... dc) { return new ContainerTag("html").with(dc); }
|
||||||
|
public static ContainerTag html(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("html"), shortAttr); }
|
||||||
|
public static ContainerTag html(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("html").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag html(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("html").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag i() { return new ContainerTag("i"); }
|
public static ContainerTag i() { return new ContainerTag("i"); }
|
||||||
public static ContainerTag i(String text) { return new ContainerTag("i").withText(text); }
|
public static ContainerTag i(String text) { return new ContainerTag("i").withText(text); }
|
||||||
|
public static ContainerTag i(DomContent... dc) { return new ContainerTag("i").with(dc); }
|
||||||
|
public static ContainerTag i(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("i"), shortAttr); }
|
||||||
|
public static ContainerTag i(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("i").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag i(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("i").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag iframe() { return new ContainerTag("iframe"); }
|
public static ContainerTag iframe() { return new ContainerTag("iframe"); }
|
||||||
|
public static ContainerTag iframe(String text) { return new ContainerTag("iframe").withText(text); }
|
||||||
|
public static ContainerTag iframe(DomContent... dc) { return new ContainerTag("iframe").with(dc); }
|
||||||
|
public static ContainerTag iframe(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("iframe"), shortAttr); }
|
||||||
|
public static ContainerTag iframe(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("iframe").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag iframe(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("iframe").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag ins() { return new ContainerTag("ins"); }
|
public static ContainerTag ins() { return new ContainerTag("ins"); }
|
||||||
public static ContainerTag ins(String text) { return new ContainerTag("ins").withText(text); }
|
public static ContainerTag ins(String text) { return new ContainerTag("ins").withText(text); }
|
||||||
|
public static ContainerTag ins(DomContent... dc) { return new ContainerTag("ins").with(dc); }
|
||||||
|
public static ContainerTag ins(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("ins"), shortAttr); }
|
||||||
|
public static ContainerTag ins(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("ins").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag ins(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("ins").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag kbd() { return new ContainerTag("kbd"); }
|
public static ContainerTag kbd() { return new ContainerTag("kbd"); }
|
||||||
|
public static ContainerTag kbd(String text) { return new ContainerTag("kbd").withText(text); }
|
||||||
|
public static ContainerTag kbd(DomContent... dc) { return new ContainerTag("kbd").with(dc); }
|
||||||
|
public static ContainerTag kbd(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("kbd"), shortAttr); }
|
||||||
|
public static ContainerTag kbd(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("kbd").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag kbd(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("kbd").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag label() { return new ContainerTag("label"); }
|
public static ContainerTag label() { return new ContainerTag("label"); }
|
||||||
public static ContainerTag label(String text) { return new ContainerTag("label").withText(text); }
|
public static ContainerTag label(String text) { return new ContainerTag("label").withText(text); }
|
||||||
|
public static ContainerTag label(DomContent... dc) { return new ContainerTag("label").with(dc); }
|
||||||
|
public static ContainerTag label(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("label"), shortAttr); }
|
||||||
|
public static ContainerTag label(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("label").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag label(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("label").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag legend() { return new ContainerTag("legend"); }
|
public static ContainerTag legend() { return new ContainerTag("legend"); }
|
||||||
public static ContainerTag legend(String text) { return new ContainerTag("legend").withText(text); }
|
public static ContainerTag legend(String text) { return new ContainerTag("legend").withText(text); }
|
||||||
|
public static ContainerTag legend(DomContent... dc) { return new ContainerTag("legend").with(dc); }
|
||||||
|
public static ContainerTag legend(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("legend"), shortAttr); }
|
||||||
|
public static ContainerTag legend(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("legend").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag legend(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("legend").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag li() { return new ContainerTag("li"); }
|
public static ContainerTag li() { return new ContainerTag("li"); }
|
||||||
public static ContainerTag li(String text) { return new ContainerTag("li").withText(text); }
|
public static ContainerTag li(String text) { return new ContainerTag("li").withText(text); }
|
||||||
|
public static ContainerTag li(DomContent... dc) { return new ContainerTag("li").with(dc); }
|
||||||
|
public static ContainerTag li(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("li"), shortAttr); }
|
||||||
|
public static ContainerTag li(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("li").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag li(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("li").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag main() { return new ContainerTag("main"); }
|
public static ContainerTag main() { return new ContainerTag("main"); }
|
||||||
|
public static ContainerTag main(String text) { return new ContainerTag("main").withText(text); }
|
||||||
|
public static ContainerTag main(DomContent... dc) { return new ContainerTag("main").with(dc); }
|
||||||
|
public static ContainerTag main(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("main"), shortAttr); }
|
||||||
|
public static ContainerTag main(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("main").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag main(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("main").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag map() { return new ContainerTag("map"); }
|
public static ContainerTag map() { return new ContainerTag("map"); }
|
||||||
|
public static ContainerTag map(String text) { return new ContainerTag("map").withText(text); }
|
||||||
|
public static ContainerTag map(DomContent... dc) { return new ContainerTag("map").with(dc); }
|
||||||
|
public static ContainerTag map(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("map"), shortAttr); }
|
||||||
|
public static ContainerTag map(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("map").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag map(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("map").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag mark() { return new ContainerTag("mark"); }
|
public static ContainerTag mark() { return new ContainerTag("mark"); }
|
||||||
|
public static ContainerTag mark(String text) { return new ContainerTag("mark").withText(text); }
|
||||||
|
public static ContainerTag mark(DomContent... dc) { return new ContainerTag("mark").with(dc); }
|
||||||
|
public static ContainerTag mark(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("mark"), shortAttr); }
|
||||||
|
public static ContainerTag mark(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("mark").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag mark(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("mark").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag menu() { return new ContainerTag("menu"); }
|
public static ContainerTag menu() { return new ContainerTag("menu"); }
|
||||||
|
public static ContainerTag menu(String text) { return new ContainerTag("menu").withText(text); }
|
||||||
|
public static ContainerTag menu(DomContent... dc) { return new ContainerTag("menu").with(dc); }
|
||||||
|
public static ContainerTag menu(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("menu"), shortAttr); }
|
||||||
|
public static ContainerTag menu(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("menu").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag menu(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("menu").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag menuitem() { return new ContainerTag("menuitem"); }
|
public static ContainerTag menuitem() { return new ContainerTag("menuitem"); }
|
||||||
|
public static ContainerTag menuitem(String text) { return new ContainerTag("menuitem").withText(text); }
|
||||||
|
public static ContainerTag menuitem(DomContent... dc) { return new ContainerTag("menuitem").with(dc); }
|
||||||
|
public static ContainerTag menuitem(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("menuitem"), shortAttr); }
|
||||||
|
public static ContainerTag menuitem(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("menuitem").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag menuitem(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("menuitem").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag meter() { return new ContainerTag("meter"); }
|
public static ContainerTag meter() { return new ContainerTag("meter"); }
|
||||||
|
public static ContainerTag meter(String text) { return new ContainerTag("meter").withText(text); }
|
||||||
|
public static ContainerTag meter(DomContent... dc) { return new ContainerTag("meter").with(dc); }
|
||||||
|
public static ContainerTag meter(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("meter"), shortAttr); }
|
||||||
|
public static ContainerTag meter(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("meter").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag meter(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("meter").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag nav() { return new ContainerTag("nav"); }
|
public static ContainerTag nav() { return new ContainerTag("nav"); }
|
||||||
|
public static ContainerTag nav(String text) { return new ContainerTag("nav").withText(text); }
|
||||||
|
public static ContainerTag nav(DomContent... dc) { return new ContainerTag("nav").with(dc); }
|
||||||
|
public static ContainerTag nav(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("nav"), shortAttr); }
|
||||||
|
public static ContainerTag nav(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("nav").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag nav(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("nav").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag noscript() { return new ContainerTag("noscript"); }
|
public static ContainerTag noscript() { return new ContainerTag("noscript"); }
|
||||||
|
public static ContainerTag noscript(String text) { return new ContainerTag("noscript").withText(text); }
|
||||||
|
public static ContainerTag noscript(DomContent... dc) { return new ContainerTag("noscript").with(dc); }
|
||||||
|
public static ContainerTag noscript(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("noscript"), shortAttr); }
|
||||||
|
public static ContainerTag noscript(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("noscript").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag noscript(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("noscript").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag object() { return new ContainerTag("object"); }
|
public static ContainerTag object() { return new ContainerTag("object"); }
|
||||||
|
public static ContainerTag object(String text) { return new ContainerTag("object").withText(text); }
|
||||||
|
public static ContainerTag object(DomContent... dc) { return new ContainerTag("object").with(dc); }
|
||||||
|
public static ContainerTag object(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("object"), shortAttr); }
|
||||||
|
public static ContainerTag object(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("object").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag object(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("object").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag ol() { return new ContainerTag("ol"); }
|
public static ContainerTag ol() { return new ContainerTag("ol"); }
|
||||||
|
public static ContainerTag ol(String text) { return new ContainerTag("ol").withText(text); }
|
||||||
|
public static ContainerTag ol(DomContent... dc) { return new ContainerTag("ol").with(dc); }
|
||||||
|
public static ContainerTag ol(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("ol"), shortAttr); }
|
||||||
|
public static ContainerTag ol(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("ol").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag ol(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("ol").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag optgroup() { return new ContainerTag("optgroup"); }
|
public static ContainerTag optgroup() { return new ContainerTag("optgroup"); }
|
||||||
|
public static ContainerTag optgroup(String text) { return new ContainerTag("optgroup").withText(text); }
|
||||||
|
public static ContainerTag optgroup(DomContent... dc) { return new ContainerTag("optgroup").with(dc); }
|
||||||
|
public static ContainerTag optgroup(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("optgroup"), shortAttr); }
|
||||||
|
public static ContainerTag optgroup(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("optgroup").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag optgroup(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("optgroup").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag option() { return new ContainerTag("option"); }
|
public static ContainerTag option() { return new ContainerTag("option"); }
|
||||||
public static ContainerTag option(String text) { return new ContainerTag("option").withText(text); }
|
public static ContainerTag option(String text) { return new ContainerTag("option").withText(text); }
|
||||||
|
public static ContainerTag option(DomContent... dc) { return new ContainerTag("option").with(dc); }
|
||||||
|
public static ContainerTag option(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("option"), shortAttr); }
|
||||||
|
public static ContainerTag option(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("option").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag option(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("option").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag output() { return new ContainerTag("output"); }
|
public static ContainerTag output() { return new ContainerTag("output"); }
|
||||||
|
public static ContainerTag output(String text) { return new ContainerTag("output").withText(text); }
|
||||||
|
public static ContainerTag output(DomContent... dc) { return new ContainerTag("output").with(dc); }
|
||||||
|
public static ContainerTag output(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("output"), shortAttr); }
|
||||||
|
public static ContainerTag output(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("output").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag output(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("output").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag p() { return new ContainerTag("p"); }
|
public static ContainerTag p() { return new ContainerTag("p"); }
|
||||||
public static ContainerTag p(String text) { return new ContainerTag("p").withText(text); }
|
public static ContainerTag p(String text) { return new ContainerTag("p").withText(text); }
|
||||||
|
public static ContainerTag p(DomContent... dc) { return new ContainerTag("p").with(dc); }
|
||||||
|
public static ContainerTag p(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("p"), shortAttr); }
|
||||||
|
public static ContainerTag p(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("p").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag p(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("p").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag pre() { return new ContainerTag("pre"); }
|
public static ContainerTag pre() { return new ContainerTag("pre"); }
|
||||||
|
public static ContainerTag pre(String text) { return new ContainerTag("pre").withText(text); }
|
||||||
|
public static ContainerTag pre(DomContent... dc) { return new ContainerTag("pre").with(dc); }
|
||||||
|
public static ContainerTag pre(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("pre"), shortAttr); }
|
||||||
|
public static ContainerTag pre(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("pre").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag pre(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("pre").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag progress() { return new ContainerTag("progress"); }
|
public static ContainerTag progress() { return new ContainerTag("progress"); }
|
||||||
|
public static ContainerTag progress(String text) { return new ContainerTag("progress").withText(text); }
|
||||||
|
public static ContainerTag progress(DomContent... dc) { return new ContainerTag("progress").with(dc); }
|
||||||
|
public static ContainerTag progress(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("progress"), shortAttr); }
|
||||||
|
public static ContainerTag progress(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("progress").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag progress(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("progress").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag q() { return new ContainerTag("q"); }
|
public static ContainerTag q() { return new ContainerTag("q"); }
|
||||||
public static ContainerTag q(String text) { return new ContainerTag("q").withText(text); }
|
public static ContainerTag q(String text) { return new ContainerTag("q").withText(text); }
|
||||||
|
public static ContainerTag q(DomContent... dc) { return new ContainerTag("q").with(dc); }
|
||||||
|
public static ContainerTag q(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("q"), shortAttr); }
|
||||||
|
public static ContainerTag q(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("q").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag q(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("q").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag rp() { return new ContainerTag("rp"); }
|
public static ContainerTag rp() { return new ContainerTag("rp"); }
|
||||||
|
public static ContainerTag rp(String text) { return new ContainerTag("rp").withText(text); }
|
||||||
|
public static ContainerTag rp(DomContent... dc) { return new ContainerTag("rp").with(dc); }
|
||||||
|
public static ContainerTag rp(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("rp"), shortAttr); }
|
||||||
|
public static ContainerTag rp(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("rp").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag rp(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("rp").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag rt() { return new ContainerTag("rt"); }
|
public static ContainerTag rt() { return new ContainerTag("rt"); }
|
||||||
|
public static ContainerTag rt(String text) { return new ContainerTag("rt").withText(text); }
|
||||||
|
public static ContainerTag rt(DomContent... dc) { return new ContainerTag("rt").with(dc); }
|
||||||
|
public static ContainerTag rt(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("rt"), shortAttr); }
|
||||||
|
public static ContainerTag rt(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("rt").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag rt(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("rt").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag ruby() { return new ContainerTag("ruby"); }
|
public static ContainerTag ruby() { return new ContainerTag("ruby"); }
|
||||||
|
public static ContainerTag ruby(String text) { return new ContainerTag("ruby").withText(text); }
|
||||||
|
public static ContainerTag ruby(DomContent... dc) { return new ContainerTag("ruby").with(dc); }
|
||||||
|
public static ContainerTag ruby(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("ruby"), shortAttr); }
|
||||||
|
public static ContainerTag ruby(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("ruby").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag ruby(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("ruby").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag s() { return new ContainerTag("s"); }
|
public static ContainerTag s() { return new ContainerTag("s"); }
|
||||||
public static ContainerTag s(String text) { return new ContainerTag("s").withText(text); }
|
public static ContainerTag s(String text) { return new ContainerTag("s").withText(text); }
|
||||||
|
public static ContainerTag s(DomContent... dc) { return new ContainerTag("s").with(dc); }
|
||||||
|
public static ContainerTag s(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("s"), shortAttr); }
|
||||||
|
public static ContainerTag s(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("s").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag s(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("s").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag samp() { return new ContainerTag("samp"); }
|
public static ContainerTag samp() { return new ContainerTag("samp"); }
|
||||||
|
public static ContainerTag samp(String text) { return new ContainerTag("samp").withText(text); }
|
||||||
|
public static ContainerTag samp(DomContent... dc) { return new ContainerTag("samp").with(dc); }
|
||||||
|
public static ContainerTag samp(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("samp"), shortAttr); }
|
||||||
|
public static ContainerTag samp(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("samp").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag samp(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("samp").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag script() { return new ContainerTag("script"); }
|
public static ContainerTag script() { return new ContainerTag("script"); }
|
||||||
|
public static ContainerTag script(String text) { return new ContainerTag("script").withText(text); }
|
||||||
|
public static ContainerTag script(DomContent... dc) { return new ContainerTag("script").with(dc); }
|
||||||
|
public static ContainerTag script(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("script"), shortAttr); }
|
||||||
|
public static ContainerTag script(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("script").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag script(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("script").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag section() { return new ContainerTag("section"); }
|
public static ContainerTag section() { return new ContainerTag("section"); }
|
||||||
|
public static ContainerTag section(String text) { return new ContainerTag("section").withText(text); }
|
||||||
|
public static ContainerTag section(DomContent... dc) { return new ContainerTag("section").with(dc); }
|
||||||
|
public static ContainerTag section(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("section"), shortAttr); }
|
||||||
|
public static ContainerTag section(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("section").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag section(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("section").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag select() { return new ContainerTag("select"); }
|
public static ContainerTag select() { return new ContainerTag("select"); }
|
||||||
|
public static ContainerTag select(String text) { return new ContainerTag("select").withText(text); }
|
||||||
|
public static ContainerTag select(DomContent... dc) { return new ContainerTag("select").with(dc); }
|
||||||
|
public static ContainerTag select(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("select"), shortAttr); }
|
||||||
|
public static ContainerTag select(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("select").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag select(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("select").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag small() { return new ContainerTag("small"); }
|
public static ContainerTag small() { return new ContainerTag("small"); }
|
||||||
public static ContainerTag small(String text) { return new ContainerTag("small").withText(text); }
|
public static ContainerTag small(String text) { return new ContainerTag("small").withText(text); }
|
||||||
|
public static ContainerTag small(DomContent... dc) { return new ContainerTag("small").with(dc); }
|
||||||
|
public static ContainerTag small(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("small"), shortAttr); }
|
||||||
|
public static ContainerTag small(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("small").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag small(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("small").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag span() { return new ContainerTag("span"); }
|
public static ContainerTag span() { return new ContainerTag("span"); }
|
||||||
public static ContainerTag span(String text) { return new ContainerTag("span").withText(text); }
|
public static ContainerTag span(String text) { return new ContainerTag("span").withText(text); }
|
||||||
|
public static ContainerTag span(DomContent... dc) { return new ContainerTag("span").with(dc); }
|
||||||
|
public static ContainerTag span(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("span"), shortAttr); }
|
||||||
|
public static ContainerTag span(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("span").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag span(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("span").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag strong() { return new ContainerTag("strong"); }
|
public static ContainerTag strong() { return new ContainerTag("strong"); }
|
||||||
public static ContainerTag strong(String text) { return new ContainerTag("strong").withText(text); }
|
public static ContainerTag strong(String text) { return new ContainerTag("strong").withText(text); }
|
||||||
|
public static ContainerTag strong(DomContent... dc) { return new ContainerTag("strong").with(dc); }
|
||||||
|
public static ContainerTag strong(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("strong"), shortAttr); }
|
||||||
|
public static ContainerTag strong(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("strong").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag strong(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("strong").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag style() { return new ContainerTag("style"); }
|
public static ContainerTag style() { return new ContainerTag("style"); }
|
||||||
|
public static ContainerTag style(String text) { return new ContainerTag("style").withText(text); }
|
||||||
|
public static ContainerTag style(DomContent... dc) { return new ContainerTag("style").with(dc); }
|
||||||
|
public static ContainerTag style(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("style"), shortAttr); }
|
||||||
|
public static ContainerTag style(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("style").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag style(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("style").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag sub() { return new ContainerTag("sub"); }
|
public static ContainerTag sub() { return new ContainerTag("sub"); }
|
||||||
public static ContainerTag sub(String text) { return new ContainerTag("sub").withText(text); }
|
public static ContainerTag sub(String text) { return new ContainerTag("sub").withText(text); }
|
||||||
|
public static ContainerTag sub(DomContent... dc) { return new ContainerTag("sub").with(dc); }
|
||||||
|
public static ContainerTag sub(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("sub"), shortAttr); }
|
||||||
|
public static ContainerTag sub(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("sub").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag sub(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("sub").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag summary() { return new ContainerTag("summary"); }
|
public static ContainerTag summary() { return new ContainerTag("summary"); }
|
||||||
public static ContainerTag summary(String text) { return new ContainerTag("summary").withText(text); }
|
public static ContainerTag summary(String text) { return new ContainerTag("summary").withText(text); }
|
||||||
|
public static ContainerTag summary(DomContent... dc) { return new ContainerTag("summary").with(dc); }
|
||||||
|
public static ContainerTag summary(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("summary"), shortAttr); }
|
||||||
|
public static ContainerTag summary(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("summary").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag summary(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("summary").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag sup() { return new ContainerTag("sup"); }
|
public static ContainerTag sup() { return new ContainerTag("sup"); }
|
||||||
public static ContainerTag sup(String text) { return new ContainerTag("sup").withText(text); }
|
public static ContainerTag sup(String text) { return new ContainerTag("sup").withText(text); }
|
||||||
|
public static ContainerTag sup(DomContent... dc) { return new ContainerTag("sup").with(dc); }
|
||||||
|
public static ContainerTag sup(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("sup"), shortAttr); }
|
||||||
|
public static ContainerTag sup(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("sup").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag sup(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("sup").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag table() { return new ContainerTag("table"); }
|
public static ContainerTag table() { return new ContainerTag("table"); }
|
||||||
|
public static ContainerTag table(String text) { return new ContainerTag("table").withText(text); }
|
||||||
|
public static ContainerTag table(DomContent... dc) { return new ContainerTag("table").with(dc); }
|
||||||
|
public static ContainerTag table(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("table"), shortAttr); }
|
||||||
|
public static ContainerTag table(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("table").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag table(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("table").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag tbody() { return new ContainerTag("tbody"); }
|
public static ContainerTag tbody() { return new ContainerTag("tbody"); }
|
||||||
|
public static ContainerTag tbody(String text) { return new ContainerTag("tbody").withText(text); }
|
||||||
|
public static ContainerTag tbody(DomContent... dc) { return new ContainerTag("tbody").with(dc); }
|
||||||
|
public static ContainerTag tbody(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("tbody"), shortAttr); }
|
||||||
|
public static ContainerTag tbody(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("tbody").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag tbody(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("tbody").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag td() { return new ContainerTag("td"); }
|
public static ContainerTag td() { return new ContainerTag("td"); }
|
||||||
public static ContainerTag td(String text) { return new ContainerTag("td").withText(text); }
|
public static ContainerTag td(String text) { return new ContainerTag("td").withText(text); }
|
||||||
|
public static ContainerTag td(DomContent... dc) { return new ContainerTag("td").with(dc); }
|
||||||
|
public static ContainerTag td(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("td"), shortAttr); }
|
||||||
|
public static ContainerTag td(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("td").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag td(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("td").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag textarea() { return new ContainerTag("textarea"); }
|
public static ContainerTag textarea() { return new ContainerTag("textarea"); }
|
||||||
|
public static ContainerTag textarea(String text) { return new ContainerTag("textarea").withText(text); }
|
||||||
|
public static ContainerTag textarea(DomContent... dc) { return new ContainerTag("textarea").with(dc); }
|
||||||
|
public static ContainerTag textarea(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("textarea"), shortAttr); }
|
||||||
|
public static ContainerTag textarea(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("textarea").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag textarea(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("textarea").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag tfoot() { return new ContainerTag("tfoot"); }
|
public static ContainerTag tfoot() { return new ContainerTag("tfoot"); }
|
||||||
|
public static ContainerTag tfoot(String text) { return new ContainerTag("tfoot").withText(text); }
|
||||||
|
public static ContainerTag tfoot(DomContent... dc) { return new ContainerTag("tfoot").with(dc); }
|
||||||
|
public static ContainerTag tfoot(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("tfoot"), shortAttr); }
|
||||||
|
public static ContainerTag tfoot(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("tfoot").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag tfoot(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("tfoot").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag th() { return new ContainerTag("th"); }
|
public static ContainerTag th() { return new ContainerTag("th"); }
|
||||||
public static ContainerTag th(String text) { return new ContainerTag("th").withText(text); }
|
public static ContainerTag th(String text) { return new ContainerTag("th").withText(text); }
|
||||||
|
public static ContainerTag th(DomContent... dc) { return new ContainerTag("th").with(dc); }
|
||||||
|
public static ContainerTag th(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("th"), shortAttr); }
|
||||||
|
public static ContainerTag th(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("th").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag th(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("th").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag thead() { return new ContainerTag("thead"); }
|
public static ContainerTag thead() { return new ContainerTag("thead"); }
|
||||||
|
public static ContainerTag thead(String text) { return new ContainerTag("thead").withText(text); }
|
||||||
|
public static ContainerTag thead(DomContent... dc) { return new ContainerTag("thead").with(dc); }
|
||||||
|
public static ContainerTag thead(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("thead"), shortAttr); }
|
||||||
|
public static ContainerTag thead(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("thead").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag thead(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("thead").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag time() { return new ContainerTag("time"); }
|
public static ContainerTag time() { return new ContainerTag("time"); }
|
||||||
|
public static ContainerTag time(String text) { return new ContainerTag("time").withText(text); }
|
||||||
|
public static ContainerTag time(DomContent... dc) { return new ContainerTag("time").with(dc); }
|
||||||
|
public static ContainerTag time(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("time"), shortAttr); }
|
||||||
|
public static ContainerTag time(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("time").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag time(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("time").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag title() { return new ContainerTag("title"); }
|
public static ContainerTag title() { return new ContainerTag("title"); }
|
||||||
public static ContainerTag title(String text) { return new ContainerTag("title").withText(text); }
|
public static ContainerTag title(String text) { return new ContainerTag("title").withText(text); }
|
||||||
|
public static ContainerTag title(DomContent... dc) { return new ContainerTag("title").with(dc); }
|
||||||
|
public static ContainerTag title(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("title"), shortAttr); }
|
||||||
|
public static ContainerTag title(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("title").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag title(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("title").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag tr() { return new ContainerTag("tr"); }
|
public static ContainerTag tr() { return new ContainerTag("tr"); }
|
||||||
|
public static ContainerTag tr(String text) { return new ContainerTag("tr").withText(text); }
|
||||||
|
public static ContainerTag tr(DomContent... dc) { return new ContainerTag("tr").with(dc); }
|
||||||
|
public static ContainerTag tr(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("tr"), shortAttr); }
|
||||||
|
public static ContainerTag tr(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("tr").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag tr(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("tr").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag u() { return new ContainerTag("u"); }
|
public static ContainerTag u() { return new ContainerTag("u"); }
|
||||||
public static ContainerTag u(String text) { return new ContainerTag("u").withText(text); }
|
public static ContainerTag u(String text) { return new ContainerTag("u").withText(text); }
|
||||||
|
public static ContainerTag u(DomContent... dc) { return new ContainerTag("u").with(dc); }
|
||||||
|
public static ContainerTag u(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("u"), shortAttr); }
|
||||||
|
public static ContainerTag u(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("u").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag u(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("u").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag ul() { return new ContainerTag("ul"); }
|
public static ContainerTag ul() { return new ContainerTag("ul"); }
|
||||||
|
public static ContainerTag ul(String text) { return new ContainerTag("ul").withText(text); }
|
||||||
|
public static ContainerTag ul(DomContent... dc) { return new ContainerTag("ul").with(dc); }
|
||||||
|
public static ContainerTag ul(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("ul"), shortAttr); }
|
||||||
|
public static ContainerTag ul(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("ul").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag ul(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("ul").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag var() { return new ContainerTag("var"); }
|
public static ContainerTag var() { return new ContainerTag("var"); }
|
||||||
|
public static ContainerTag var(String text) { return new ContainerTag("var").withText(text); }
|
||||||
|
public static ContainerTag var(DomContent... dc) { return new ContainerTag("var").with(dc); }
|
||||||
|
public static ContainerTag var(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("var"), shortAttr); }
|
||||||
|
public static ContainerTag var(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("var").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag var(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("var").with(dc), shortAttr); }
|
||||||
|
|
||||||
public static ContainerTag video() { return new ContainerTag("video"); }
|
public static ContainerTag video() { return new ContainerTag("video"); }
|
||||||
|
public static ContainerTag video(String text) { return new ContainerTag("video").withText(text); }
|
||||||
|
public static ContainerTag video(DomContent... dc) { return new ContainerTag("video").with(dc); }
|
||||||
|
public static ContainerTag video(Attr.ShortForm shortAttr) { return Attr.addTo(new ContainerTag("video"), shortAttr); }
|
||||||
|
public static ContainerTag video(Attr.ShortForm shortAttr, String text) { return Attr.addTo(new ContainerTag("video").withText(text), shortAttr); }
|
||||||
|
public static ContainerTag video(Attr.ShortForm shortAttr, DomContent... dc) { return Attr.addTo(new ContainerTag("video").with(dc), shortAttr); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,114 +1,174 @@
|
|||||||
package j2html.attributes;
|
package j2html.attributes;
|
||||||
|
|
||||||
|
import j2html.tags.Tag;
|
||||||
|
|
||||||
public class Attr {
|
public class Attr {
|
||||||
public static String HIDDEN = "hidden";
|
|
||||||
public static String HIGH = "high";
|
public static class ShortForm {
|
||||||
public static String HREF = "href";
|
String id;
|
||||||
public static String HREFLANG = "hreflang";
|
String classes;
|
||||||
public static String HTTP_EQUIV = "http-equiv";
|
|
||||||
public static String ICON = "icon";
|
private ShortForm(String id, String classes) {
|
||||||
public static String ID = "id";
|
this.id = id;
|
||||||
public static String ISMAP = "ismap";
|
this.classes = classes;
|
||||||
public static String ITEMPROP = "itemprop";
|
}
|
||||||
public static String KEYTYPE = "keytype";
|
|
||||||
public static String KIND = "kind";
|
boolean hasId() {
|
||||||
public static String LABEL = "label";
|
return id != null && !"".equals(id);
|
||||||
public static String LANG = "lang";
|
}
|
||||||
public static String LANGUAGE = "language";
|
|
||||||
public static String LIST = "list";
|
boolean hasClasses() {
|
||||||
public static String LOOP = "loop";
|
return classes != null && !"".equals(classes);
|
||||||
public static String LOW = "low";
|
}
|
||||||
public static String MANIFEST = "manifest";
|
}
|
||||||
public static String MAX = "max";
|
|
||||||
public static String MAXLENGTH = "maxlength";
|
public static ShortForm shortFormFromAttrsString(String attrs) {
|
||||||
public static String MEDIA = "media";
|
if (!attrs.contains(".") && !attrs.contains(("#"))) {
|
||||||
public static String METHOD = "method";
|
throw new IllegalArgumentException("String must contain either id (#) or class (.)");
|
||||||
public static String MIN = "min";
|
}
|
||||||
public static String MULTIPLE = "multiple";
|
if (attrs.split("#").length > 2) {
|
||||||
public static String NAME = "name";
|
throw new IllegalArgumentException("Only one id (#) allowed");
|
||||||
public static String NOVALIDATE = "novalidate";
|
}
|
||||||
public static String OPEN = "open";
|
String id = "";
|
||||||
public static String OPTIMUM = "optimum";
|
StringBuilder classes = new StringBuilder();
|
||||||
public static String PATTERN = "pattern";
|
for (String attr : attrs.split("\\.")) {
|
||||||
public static String PING = "ping";
|
if (attr.contains("#")) {
|
||||||
public static String PLACEHOLDER = "placeholder";
|
if (!attr.startsWith("#")) {
|
||||||
public static String POSTER = "poster";
|
throw new IllegalArgumentException("# cannot be in the middle of string");
|
||||||
public static String PRELOAD = "preload";
|
}
|
||||||
public static String PUBDATE = "pubdate";
|
id = attr.replace("#", "");
|
||||||
public static String RADIOGROUP = "radiogroup";
|
} else {
|
||||||
public static String READONLY = "readonly";
|
classes.append(attr).append(" ");
|
||||||
public static String REL = "rel";
|
}
|
||||||
public static String REQUIRED = "required";
|
}
|
||||||
public static String REVERSED = "reversed";
|
return new ShortForm(id.trim(), classes.toString().trim());
|
||||||
public static String ROWS = "rows";
|
}
|
||||||
public static String ROWSPAN = "rowspan";
|
|
||||||
public static String SANDBOX = "sandbox";
|
public static <T extends Tag<T>> T addTo(T tag, ShortForm shortForm) {
|
||||||
public static String SPELLCHECK = "spellcheck";
|
if (shortForm.hasId() && shortForm.hasClasses()) {
|
||||||
public static String SCOPE = "scope";
|
return tag.withId(shortForm.id).withClass(shortForm.classes);
|
||||||
public static String SCOPED = "scoped";
|
}
|
||||||
public static String SEAMLESS = "seamless";
|
if (shortForm.hasId()) {
|
||||||
public static String SELECTED = "selected";
|
return tag.withId(shortForm.id);
|
||||||
public static String SHAPE = "shape";
|
}
|
||||||
public static String SIZE = "size";
|
if (shortForm.hasClasses()) {
|
||||||
public static String SIZES = "sizes";
|
return tag.withClass(shortForm.classes);
|
||||||
public static String SPAN = "span";
|
}
|
||||||
public static String SRC = "src";
|
return tag;
|
||||||
public static String SRCDOC = "srcdoc";
|
}
|
||||||
public static String SRCLANG = "srclang";
|
|
||||||
public static String SRCSET = "srcset";
|
private Attr() {
|
||||||
public static String START = "start";
|
}
|
||||||
public static String STEP = "step";
|
|
||||||
public static String STYLE = "style";
|
public static final String ACCEPT = "accept";
|
||||||
public static String SUMMARY = "summary";
|
public static final String ACCEPT_CHARSET = "accept-charset";
|
||||||
public static String TABINDEX = "tabindex";
|
public static final String ACCESSKEY = "accesskey";
|
||||||
public static String TARGET = "target";
|
public static final String ACTION = "action";
|
||||||
public static String TITLE = "title";
|
public static final String ALIGN = "align";
|
||||||
public static String TYPE = "type";
|
public static final String ALT = "alt";
|
||||||
public static String USEMAP = "usemap";
|
public static final String ASYNC = "async";
|
||||||
public static String VALUE = "value";
|
public static final String AUTOCOMPLETE = "autocomplete";
|
||||||
public static String WIDTH = "width";
|
public static final String AUTOFOCUS = "autofocus";
|
||||||
public static String WRAP = "wrap";
|
public static final String AUTOPLAY = "autoplay";
|
||||||
public static String BORDER = "border";
|
public static final String AUTOSAVE = "autosave";
|
||||||
public static String BUFFERED = "buffered";
|
public static final String BORDER = "border";
|
||||||
public static String CHALLENGE = "challenge";
|
public static final String BUFFERED = "buffered";
|
||||||
public static String CHARSET = "charset";
|
public static final String CHALLENGE = "challenge";
|
||||||
public static String CHECKED = "checked";
|
public static final String CHARSET = "charset";
|
||||||
public static String CITE = "cite";
|
public static final String CHECKED = "checked";
|
||||||
public static String CLASS = "class";
|
public static final String CITE = "cite";
|
||||||
public static String COLOR = "color";
|
public static final String CLASS = "class";
|
||||||
public static String COLS = "cols";
|
public static final String COLOR = "color";
|
||||||
public static String COLSPAN = "colspan";
|
public static final String COLS = "cols";
|
||||||
public static String CONTENT = "content";
|
public static final String COLSPAN = "colspan";
|
||||||
public static String CONTENTEDITABLE = "contenteditable";
|
public static final String CONTENT = "content";
|
||||||
public static String CONTEXTMENU = "contextmenu";
|
public static final String CONTENTEDITABLE = "contenteditable";
|
||||||
public static String CONTROLS = "controls";
|
public static final String CONTEXTMENU = "contextmenu";
|
||||||
public static String COORDS = "coords";
|
public static final String CONTROLS = "controls";
|
||||||
public static String DATA = "data";
|
public static final String COORDS = "coords";
|
||||||
public static String DATETIME = "datetime";
|
public static final String DATA = "data";
|
||||||
public static String DEFAULT = "default";
|
public static final String DATETIME = "datetime";
|
||||||
public static String DEFER = "defer";
|
public static final String DEFAULT = "default";
|
||||||
public static String DIR = "dir";
|
public static final String DEFER = "defer";
|
||||||
public static String DIRNAME = "dirname";
|
public static final String DIR = "dir";
|
||||||
public static String DISABLED = "disabled";
|
public static final String DIRNAME = "dirname";
|
||||||
public static String DOWNLOAD = "download";
|
public static final String DISABLED = "disabled";
|
||||||
public static String DRAGGABLE = "draggable";
|
public static final String DOWNLOAD = "download";
|
||||||
public static String DROPZONE = "dropzone";
|
public static final String DRAGGABLE = "draggable";
|
||||||
public static String ENCTYPE = "enctype";
|
public static final String DROPZONE = "dropzone";
|
||||||
public static String FOR = "for";
|
public static final String ENCTYPE = "enctype";
|
||||||
public static String FORM = "form";
|
public static final String FOR = "for";
|
||||||
public static String FORMACTION = "formaction";
|
public static final String FORM = "form";
|
||||||
public static String HEADERS = "headers";
|
public static final String FORMACTION = "formaction";
|
||||||
public static String HEIGHT = "height";
|
public static final String HEADERS = "headers";
|
||||||
public static String ACCEPT = "accept";
|
public static final String HEIGHT = "height";
|
||||||
public static String ACCEPT_CHARSET = "accept-charset";
|
public static final String HIDDEN = "hidden";
|
||||||
public static String ACCESSKEY = "accesskey";
|
public static final String HIGH = "high";
|
||||||
public static String ACTION = "action";
|
public static final String HREF = "href";
|
||||||
public static String ALIGN = "align";
|
public static final String HREFLANG = "hreflang";
|
||||||
public static String ALT = "alt";
|
public static final String HTTP_EQUIV = "http-equiv";
|
||||||
public static String ASYNC = "async";
|
public static final String ICON = "icon";
|
||||||
public static String AUTOCOMPLETE = "autocomplete";
|
public static final String ID = "id";
|
||||||
public static String AUTOFOCUS = "autofocus";
|
public static final String ISMAP = "ismap";
|
||||||
public static String AUTOPLAY = "autoplay";
|
public static final String ITEMPROP = "itemprop";
|
||||||
public static String AUTOSAVE = "autosave";
|
public static final String KEYTYPE = "keytype";
|
||||||
|
public static final String KIND = "kind";
|
||||||
|
public static final String LABEL = "label";
|
||||||
|
public static final String LANG = "lang";
|
||||||
|
public static final String LANGUAGE = "language";
|
||||||
|
public static final String LIST = "list";
|
||||||
|
public static final String LOOP = "loop";
|
||||||
|
public static final String LOW = "low";
|
||||||
|
public static final String MANIFEST = "manifest";
|
||||||
|
public static final String MAX = "max";
|
||||||
|
public static final String MAXLENGTH = "maxlength";
|
||||||
|
public static final String MEDIA = "media";
|
||||||
|
public static final String METHOD = "method";
|
||||||
|
public static final String MIN = "min";
|
||||||
|
public static final String MULTIPLE = "multiple";
|
||||||
|
public static final String NAME = "name";
|
||||||
|
public static final String NOVALIDATE = "novalidate";
|
||||||
|
public static final String OPEN = "open";
|
||||||
|
public static final String OPTIMUM = "optimum";
|
||||||
|
public static final String PATTERN = "pattern";
|
||||||
|
public static final String PING = "ping";
|
||||||
|
public static final String PLACEHOLDER = "placeholder";
|
||||||
|
public static final String POSTER = "poster";
|
||||||
|
public static final String PRELOAD = "preload";
|
||||||
|
public static final String PUBDATE = "pubdate";
|
||||||
|
public static final String RADIOGROUP = "radiogroup";
|
||||||
|
public static final String READONLY = "readonly";
|
||||||
|
public static final String REL = "rel";
|
||||||
|
public static final String REQUIRED = "required";
|
||||||
|
public static final String REVERSED = "reversed";
|
||||||
|
public static final String ROLE = "role";
|
||||||
|
public static final String ROWS = "rows";
|
||||||
|
public static final String ROWSPAN = "rowspan";
|
||||||
|
public static final String SANDBOX = "sandbox";
|
||||||
|
public static final String SCOPE = "scope";
|
||||||
|
public static final String SCOPED = "scoped";
|
||||||
|
public static final String SEAMLESS = "seamless";
|
||||||
|
public static final String SELECTED = "selected";
|
||||||
|
public static final String SHAPE = "shape";
|
||||||
|
public static final String SIZE = "size";
|
||||||
|
public static final String SIZES = "sizes";
|
||||||
|
public static final String SPAN = "span";
|
||||||
|
public static final String SPELLCHECK = "spellcheck";
|
||||||
|
public static final String SRC = "src";
|
||||||
|
public static final String SRCDOC = "srcdoc";
|
||||||
|
public static final String SRCLANG = "srclang";
|
||||||
|
public static final String SRCSET = "srcset";
|
||||||
|
public static final String START = "start";
|
||||||
|
public static final String STEP = "step";
|
||||||
|
public static final String STYLE = "style";
|
||||||
|
public static final String SUMMARY = "summary";
|
||||||
|
public static final String TABINDEX = "tabindex";
|
||||||
|
public static final String TARGET = "target";
|
||||||
|
public static final String TITLE = "title";
|
||||||
|
public static final String TYPE = "type";
|
||||||
|
public static final String USEMAP = "usemap";
|
||||||
|
public static final String VALUE = "value";
|
||||||
|
public static final String WIDTH = "width";
|
||||||
|
public static final String WRAP = "wrap";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package j2html.attributes;
|
package j2html.attributes;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringEscapeUtils.*;
|
|
||||||
|
import j2html.Config;
|
||||||
|
|
||||||
public class Attribute {
|
public class Attribute {
|
||||||
private String name;
|
private String name;
|
||||||
@@ -8,7 +9,7 @@ public class Attribute {
|
|||||||
|
|
||||||
public Attribute(String name, String value) {
|
public Attribute(String name, String value) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.value = escapeHtml4(value);
|
this.value = Config.textEscaper.escape(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Attribute(String name) {
|
public Attribute(String name) {
|
||||||
@@ -17,8 +18,12 @@ public class Attribute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String render() {
|
public String render() {
|
||||||
if (name == null) { return ""; }
|
if (name == null) {
|
||||||
if (value == null) { return " "+name; }
|
return "";
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
return " " + name;
|
||||||
|
}
|
||||||
return (" " + name + "=\"" + value + "\"");
|
return (" " + name + "=\"" + value + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,88 +1,108 @@
|
|||||||
package j2html.tags;
|
package j2html.tags;
|
||||||
|
|
||||||
import j2html.attributes.Attr;
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ContainerTag extends Tag {
|
public class ContainerTag extends Tag<ContainerTag> {
|
||||||
|
|
||||||
public List<Tag> children;
|
private List<DomContent> children;
|
||||||
|
|
||||||
public ContainerTag(String tagType) {
|
public ContainerTag(String tagName) {
|
||||||
super(tagType);
|
super(tagName);
|
||||||
this.children = new ArrayList<>();
|
this.children = new ArrayList<DomContent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a tag to the end of this element
|
* Appends a DomContent-object to the end of this element
|
||||||
*
|
*
|
||||||
* @param child tag to be appended
|
* @param child DomContent-object to be appended
|
||||||
* @return itself for easy chaining
|
* @return itself for easy chaining
|
||||||
*/
|
*/
|
||||||
public ContainerTag with(Tag child) {
|
public ContainerTag with(DomContent child) {
|
||||||
if (this == child) {
|
if (this == child) {
|
||||||
throw new Error("Cannot append a tag to itself.");
|
throw new RuntimeException("Cannot append a tag to itself.");
|
||||||
|
}
|
||||||
|
if (child == null) {
|
||||||
|
return this; // in some cases, like when using iff(), we ignore null children
|
||||||
}
|
}
|
||||||
child.setParent(this);
|
|
||||||
children.add(child);
|
children.add(child);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call with-method based on condition
|
* Call with-method based on condition
|
||||||
* {@link #with(Tag child)}
|
* {@link #with(DomContent child)}
|
||||||
|
*
|
||||||
|
* @param condition the condition to use
|
||||||
|
* @param child DomContent-object to be appended if condition met
|
||||||
|
* @return itself for easy chaining
|
||||||
*/
|
*/
|
||||||
public ContainerTag condWith(boolean condition, Tag child) {
|
public ContainerTag condWith(boolean condition, DomContent child) {
|
||||||
return condition ? this.with(child) : this;
|
return condition ? this.with(child) : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a list of tags to the end of this element
|
* Appends a list of DomContent-objects to the end of this element
|
||||||
*
|
*
|
||||||
* @param children tags to be appended
|
* @param children DomContent-objects to be appended
|
||||||
* @return itself for easy chaining
|
* @return itself for easy chaining
|
||||||
*/
|
*/
|
||||||
public ContainerTag with(List<Tag> children) {
|
public ContainerTag with(Iterable<? extends DomContent> children) {
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
for (Tag child : children) {
|
for (DomContent child : children) {
|
||||||
this.with(child);
|
this.with(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call with-method based on condition
|
* Call with-method based on condition
|
||||||
* {@link #with(List children)}
|
* {@link #with(java.lang.Iterable)}
|
||||||
|
*
|
||||||
|
* @param condition the condition to use
|
||||||
|
* @param children DomContent-objects to be appended if condition met
|
||||||
|
* @return itself for easy chaining
|
||||||
*/
|
*/
|
||||||
public ContainerTag condWith(boolean condition, List<Tag> children) {
|
public ContainerTag condWith(boolean condition, Iterable<? extends DomContent> children) {
|
||||||
return condition ? this.with(children) : this;
|
return condition ? this.with(children) : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends the tags to the end of this element
|
* Appends the DomContent-objects to the end of this element
|
||||||
*
|
*
|
||||||
* @param children tags to be appended
|
* @param children DomContent-objects to be appended
|
||||||
* @return itself for easy chaining
|
* @return itself for easy chaining
|
||||||
*/
|
*/
|
||||||
public ContainerTag with(Tag... children) {
|
public ContainerTag with(DomContent... children) {
|
||||||
for (Tag aChildren : children) {
|
for (DomContent child : children) {
|
||||||
with(aChildren);
|
with(child);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call with-method based on condition
|
* Call with-method based on condition
|
||||||
* {@link #with(Tag... children)}
|
* {@link #with(DomContent... children)}
|
||||||
|
*
|
||||||
|
* @param condition the condition to use
|
||||||
|
* @param children DomContent-objects to be appended if condition met
|
||||||
|
* @return itself for easy chaining
|
||||||
*/
|
*/
|
||||||
public ContainerTag condWith(boolean condition, Tag... children) {
|
public ContainerTag condWith(boolean condition, DomContent... children) {
|
||||||
return condition ? this.with(children) : this;
|
return condition ? this.with(children) : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a text tag to this element
|
* Appends a Text-object to this element
|
||||||
*
|
*
|
||||||
* @param text the text to be appended
|
* @param text the text to be appended
|
||||||
* @return itself for easy chaining
|
* @return itself for easy chaining
|
||||||
@@ -92,33 +112,22 @@ public class ContainerTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a custom attribute
|
* Gets number of child nodes this tag element contains
|
||||||
|
*/
|
||||||
|
public int getNumChildren() {
|
||||||
|
return children.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the ContainerTag and its children
|
||||||
*
|
*
|
||||||
* @param attribute the attribute name
|
* @return the rendered string
|
||||||
* @param value the attribute value
|
|
||||||
* @return itself for easy chaining
|
|
||||||
*/
|
|
||||||
public ContainerTag attr(String attribute, String value) {
|
|
||||||
setAttribute(attribute, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call attr-method based on condition
|
|
||||||
* {@link #attr(String attribute, String value)}
|
|
||||||
*/
|
|
||||||
public ContainerTag condAttr(boolean condition, String attribute, String value) {
|
|
||||||
return condition ? attr(attribute, value) : this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the tag and its children
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String render() {
|
public String render() {
|
||||||
StringBuilder rendered = new StringBuilder(renderOpenTag());
|
StringBuilder rendered = new StringBuilder(renderOpenTag());
|
||||||
if (children != null && children.size() > 0) {
|
if (children != null && !children.isEmpty()) {
|
||||||
for (Tag child : children) {
|
for (DomContent child : children) {
|
||||||
rendered.append(child.render());
|
rendered.append(child.render());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,56 +136,14 @@ public class ContainerTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public void render(Appendable writer) throws IOException {
|
||||||
return this.render();
|
writer.append(renderOpenTag());
|
||||||
|
if (children != null && !children.isEmpty()) {
|
||||||
|
for (DomContent child : children) {
|
||||||
|
child.render(writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.append(renderCloseTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Methods below this point are convenience methods
|
|
||||||
* that call attr with a predefined attribute.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//TODO: TEST ?
|
|
||||||
public ContainerTag isAutoComplete() { return attr(Attr.AUTOCOMPLETE, null); }
|
|
||||||
public ContainerTag isAutoFocus() { return attr(Attr.AUTOFOCUS, null); }
|
|
||||||
public ContainerTag isHidden() { return attr(Attr.HIDDEN, null); }
|
|
||||||
public ContainerTag isRequired() { return attr(Attr.REQUIRED, null); }
|
|
||||||
public ContainerTag withAlt(String alt) { return attr(Attr.ALT, alt); }
|
|
||||||
public ContainerTag withAction(String action) { return attr(Attr.ACTION, action); }
|
|
||||||
public ContainerTag withCharset(String charset) { return attr(Attr.CHARSET, charset); }
|
|
||||||
public ContainerTag withClass(String className) { return attr(Attr.CLASS, className); }
|
|
||||||
public ContainerTag withContent(String content) { return attr(Attr.CONTENT, content); }
|
|
||||||
public ContainerTag withHref(String href) { return attr(Attr.HREF, href); }
|
|
||||||
public ContainerTag withId(String id) { return attr(Attr.ID, id); }
|
|
||||||
public ContainerTag withData(String dataAttr, String value) { return attr(Attr.DATA + "-" + dataAttr, value); }
|
|
||||||
public ContainerTag withMethod(String method) { return attr(Attr.METHOD, method); }
|
|
||||||
public ContainerTag withName(String name) { return attr(Attr.NAME, name); }
|
|
||||||
public ContainerTag withPlaceholder(String placeholder) { return attr(Attr.PLACEHOLDER, placeholder); }
|
|
||||||
public ContainerTag withTarget(String target) { return attr(Attr.TARGET, target); }
|
|
||||||
public ContainerTag withType(String type) { return attr(Attr.TYPE, type); }
|
|
||||||
public ContainerTag withRel(String rel) { return attr(Attr.REL, rel); }
|
|
||||||
public ContainerTag withSrc(String src) { return attr(Attr.SRC, src); }
|
|
||||||
public ContainerTag withValue(String value) { return attr(Attr.VALUE, value); }
|
|
||||||
|
|
||||||
public ContainerTag withCondAutoComplete(boolean condition) { return condAttr(condition, Attr.AUTOCOMPLETE, null); }
|
|
||||||
public ContainerTag withCondAutoFocus(boolean condition) { return condAttr(condition, Attr.AUTOFOCUS, null); }
|
|
||||||
public ContainerTag withCondHidden(boolean condition) { return condAttr(condition, Attr.HIDDEN, null); }
|
|
||||||
public ContainerTag withCondRequired(boolean condition) { return condAttr(condition, Attr.REQUIRED, null); }
|
|
||||||
public ContainerTag withCondAlt(boolean condition, String alt) { return condAttr(condition, Attr.ALT, alt); }
|
|
||||||
public ContainerTag withCondAction(boolean condition, String action) { return condAttr(condition, Attr.ACTION, action); }
|
|
||||||
public ContainerTag withCharset(boolean condition, String charset) { return condAttr(condition, Attr.CHARSET, charset); }
|
|
||||||
public ContainerTag withCondClass(boolean condition, String className) { return condAttr(condition, Attr.CLASS, className); }
|
|
||||||
public ContainerTag withCondContent(boolean condition, String content) { return condAttr(condition, Attr.CONTENT, content); }
|
|
||||||
public ContainerTag withCondHref(boolean condition, String href) { return condAttr(condition, Attr.HREF, href); }
|
|
||||||
public ContainerTag withCondId(boolean condition, String id) { return condAttr(condition, Attr.ID, id); }
|
|
||||||
public ContainerTag withCondData(boolean condition, String dataAttr, String value) { return condAttr(condition, Attr.DATA + "-" + dataAttr, value); }
|
|
||||||
public ContainerTag withCondMethod(boolean condition, String method) { return condAttr(condition, Attr.METHOD, method); }
|
|
||||||
public ContainerTag withCondName(boolean condition, String name) { return condAttr(condition, Attr.NAME, name); }
|
|
||||||
public ContainerTag withCondPlaceholder(boolean condition, String placeholder) { return condAttr(condition, Attr.PLACEHOLDER, placeholder); }
|
|
||||||
public ContainerTag withCondTarget(boolean condition, String target) { return condAttr(condition, Attr.TARGET, target); }
|
|
||||||
public ContainerTag withCondType(boolean condition, String type) { return condAttr(condition, Attr.TYPE, type); }
|
|
||||||
public ContainerTag withCondRel(boolean condition, String rel) { return condAttr(condition, Attr.REL, rel); }
|
|
||||||
public ContainerTag withCondSrc(boolean condition, String src) { return condAttr(condition, Attr.SRC, src); }
|
|
||||||
public ContainerTag withCondValue(boolean condition, String value) { return condAttr(condition, Attr.VALUE, value); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/main/java/j2html/tags/DomContent.java
Normal file
18
src/main/java/j2html/tags/DomContent.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package j2html.tags;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public abstract class DomContent {
|
||||||
|
|
||||||
|
public abstract String render();
|
||||||
|
|
||||||
|
public void render(Appendable writer) throws IOException {
|
||||||
|
writer.append(render());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return render();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
src/main/java/j2html/tags/DomContentJoiner.java
Normal file
24
src/main/java/j2html/tags/DomContentJoiner.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package j2html.tags;
|
||||||
|
|
||||||
|
public class DomContentJoiner {
|
||||||
|
|
||||||
|
public static UnescapedText join(CharSequence delimiter, boolean fixPeriodAndCommaSpacing, Object... stringOrDomObjects) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Object o : stringOrDomObjects) {
|
||||||
|
if (o instanceof String) {
|
||||||
|
sb.append(((String) o).trim()).append(delimiter);
|
||||||
|
} else if (o instanceof DomContent) {
|
||||||
|
sb.append(((DomContent) o).render().trim()).append(delimiter);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("You can only join DomContent and String objects");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String joined = sb.toString().trim();
|
||||||
|
if (fixPeriodAndCommaSpacing) {
|
||||||
|
joined = joined.replaceAll("\\s\\.", ".");
|
||||||
|
joined = joined.replaceAll("\\s\\,", ",");
|
||||||
|
}
|
||||||
|
return new UnescapedText(joined);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,94 +1,14 @@
|
|||||||
package j2html.tags;
|
package j2html.tags;
|
||||||
|
|
||||||
import j2html.attributes.Attr;
|
public class EmptyTag extends Tag<EmptyTag> {
|
||||||
import j2html.attributes.Attribute;
|
|
||||||
|
|
||||||
public class EmptyTag extends Tag {
|
public EmptyTag(String tagName) {
|
||||||
|
super(tagName);
|
||||||
public EmptyTag(String tagType) {
|
|
||||||
super(tagType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a custom attribute
|
|
||||||
*
|
|
||||||
* @param attribute the attribute name
|
|
||||||
* @param value the attribute value
|
|
||||||
* @return itself for easy chaining
|
|
||||||
*/
|
|
||||||
public EmptyTag attr(String attribute, String value) {
|
|
||||||
setAttribute(attribute, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call attr-method based on condition
|
|
||||||
* {@link #attr(String attribute, String value)}
|
|
||||||
*/
|
|
||||||
public EmptyTag condAttr(boolean condition, String attribute, String value) {
|
|
||||||
return condition ? attr(attribute, value) : this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String render() {
|
|
||||||
String tagAttributes = "";
|
|
||||||
for (Attribute attribute : attributes) {
|
|
||||||
tagAttributes += attribute;
|
|
||||||
}
|
|
||||||
return "<" + tag + tagAttributes + ">";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String render() {
|
||||||
return this.render();
|
return renderOpenTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Methods below this point are convenience methods
|
|
||||||
* that call attr with a predefined attribute.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//TODO: TEST ?
|
|
||||||
public EmptyTag isAutoComplete() { return attr(Attr.AUTOCOMPLETE, null); }
|
|
||||||
public EmptyTag isAutoFocus() { return attr(Attr.AUTOFOCUS, null); }
|
|
||||||
public EmptyTag isHidden() { return attr(Attr.HIDDEN, null); }
|
|
||||||
public EmptyTag isRequired() { return attr(Attr.REQUIRED, null); }
|
|
||||||
public EmptyTag withAlt(String alt) { return attr(Attr.ALT, alt); }
|
|
||||||
public EmptyTag withAction(String action) { return attr(Attr.ACTION, action); }
|
|
||||||
public EmptyTag withCharset(String charset) { return attr(Attr.CHARSET, charset); }
|
|
||||||
public EmptyTag withClass(String className) { return attr(Attr.CLASS, className); }
|
|
||||||
public EmptyTag withContent(String content) { return attr(Attr.CONTENT, content); }
|
|
||||||
public EmptyTag withHref(String href) { return attr(Attr.HREF, href); }
|
|
||||||
public EmptyTag withId(String id) { return attr(Attr.ID, id); }
|
|
||||||
public EmptyTag withData(String dataAttr, String value) { return attr(Attr.DATA + "-" + dataAttr, value); }
|
|
||||||
public EmptyTag withMethod(String method) { return attr(Attr.METHOD, method); }
|
|
||||||
public EmptyTag withName(String name) { return attr(Attr.NAME, name); }
|
|
||||||
public EmptyTag withPlaceholder(String placeholder) { return attr(Attr.PLACEHOLDER, placeholder); }
|
|
||||||
public EmptyTag withTarget(String target) { return attr(Attr.TARGET, target); }
|
|
||||||
public EmptyTag withType(String type) { return attr(Attr.TYPE, type); }
|
|
||||||
public EmptyTag withRel(String rel) { return attr(Attr.REL, rel); }
|
|
||||||
public EmptyTag withSrc(String src) { return attr(Attr.SRC, src); }
|
|
||||||
public EmptyTag withValue(String value) { return attr(Attr.VALUE, value); }
|
|
||||||
|
|
||||||
public EmptyTag withCondAutoComplete(boolean condition) { return condAttr(condition, Attr.AUTOCOMPLETE, null); }
|
|
||||||
public EmptyTag withCondAutoFocus(boolean condition) { return condAttr(condition, Attr.AUTOFOCUS, null); }
|
|
||||||
public EmptyTag withCondHidden(boolean condition) { return condAttr(condition, Attr.HIDDEN, null); }
|
|
||||||
public EmptyTag withCondRequired(boolean condition) { return condAttr(condition, Attr.REQUIRED, null); }
|
|
||||||
public EmptyTag withCondAlt(boolean condition, String alt) { return condAttr(condition, Attr.ALT, alt); }
|
|
||||||
public EmptyTag withCondAction(boolean condition, String action) { return condAttr(condition, Attr.ACTION, action); }
|
|
||||||
public EmptyTag withCharset(boolean condition, String charset) { return condAttr(condition, Attr.CHARSET, charset); }
|
|
||||||
public EmptyTag withCondClass(boolean condition, String className) { return condAttr(condition, Attr.CLASS, className); }
|
|
||||||
public EmptyTag withCondContent(boolean condition, String content) { return condAttr(condition, Attr.CONTENT, content); }
|
|
||||||
public EmptyTag withCondHref(boolean condition, String href) { return condAttr(condition, Attr.HREF, href); }
|
|
||||||
public EmptyTag withCondId(boolean condition, String id) { return condAttr(condition, Attr.ID, id); }
|
|
||||||
public EmptyTag withCondData(boolean condition, String dataAttr, String value) { return condAttr(condition, Attr.DATA + "-" + dataAttr, value); }
|
|
||||||
public EmptyTag withCondMethod(boolean condition, String method) { return condAttr(condition, Attr.METHOD, method); }
|
|
||||||
public EmptyTag withCondName(boolean condition, String name) { return condAttr(condition, Attr.NAME, name); }
|
|
||||||
public EmptyTag withCondPlaceholder(boolean condition, String placeholder) { return condAttr(condition, Attr.PLACEHOLDER, placeholder); }
|
|
||||||
public EmptyTag withCondTarget(boolean condition, String target) { return condAttr(condition, Attr.TARGET, target); }
|
|
||||||
public EmptyTag withCondType(boolean condition, String type) { return condAttr(condition, Attr.TYPE, type); }
|
|
||||||
public EmptyTag withCondRel(boolean condition, String rel) { return condAttr(condition, Attr.REL, rel); }
|
|
||||||
public EmptyTag withCondSrc(boolean condition, String src) { return condAttr(condition, Attr.SRC, src); }
|
|
||||||
public EmptyTag withCondValue(boolean condition, String value) { return condAttr(condition, Attr.VALUE, value); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package j2html.tags;
|
package j2html.tags;
|
||||||
|
|
||||||
import j2html.utils.*;
|
import java.io.BufferedReader;
|
||||||
import java.nio.file.*;
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import j2html.utils.CSSMin;
|
||||||
|
import j2html.utils.JSMin;
|
||||||
|
|
||||||
import static j2html.TagCreator.*;
|
import static j2html.TagCreator.*;
|
||||||
|
|
||||||
public class InlineStaticResource {
|
public class InlineStaticResource {
|
||||||
@@ -9,34 +14,39 @@ public class InlineStaticResource {
|
|||||||
public enum TargetFormat {CSS_MIN, CSS, JS_MIN, JS}
|
public enum TargetFormat {CSS_MIN, CSS, JS_MIN, JS}
|
||||||
|
|
||||||
public static ContainerTag get(String path, TargetFormat format) {
|
public static ContainerTag get(String path, TargetFormat format) {
|
||||||
ContainerTag errorAlert = script().with(unsafeHtml("alert('Unable to read file. File: \"" + path + "\", Type: \"" + format + "\"')"));
|
|
||||||
String fileString = getFileAsString(path);
|
String fileString = getFileAsString(path);
|
||||||
if(fileString != null) {
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case CSS_MIN : return style().with(unsafeHtml(compressCss(fileString)));
|
case CSS_MIN : return style().with(rawHtml(CSSMin.compress(fileString)));
|
||||||
case JS_MIN : return script().with(unsafeHtml(compressJs(fileString, path)));
|
case JS_MIN : return script().with(rawHtml(JSMin.compressJs(fileString)));
|
||||||
case CSS : return style().with(unsafeHtml(fileString));
|
case CSS : return style().with(rawHtml(fileString));
|
||||||
case JS : return script().with(unsafeHtml(fileString));
|
case JS : return script().with(rawHtml(fileString));
|
||||||
default : return errorAlert;
|
default : throw new RuntimeException("Invalid target format");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errorAlert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getFileAsString(String path) {
|
public static String getFileAsString(String path) {
|
||||||
try {
|
try {
|
||||||
return new String(Files.readAllBytes(Paths.get(InlineStaticResource.class.getResource(path).toURI())), "UTF-8");
|
return readFileAsString(InlineStaticResource.class.getResource(path).getPath());
|
||||||
} catch (Exception e) {
|
} catch (Exception e1) {
|
||||||
return null;
|
try {
|
||||||
|
return readFileAsString(path);
|
||||||
|
} catch (Exception e2) {
|
||||||
|
throw new RuntimeException("Couldn't find file with path='" + path + "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String compressCss(String code) {
|
/**
|
||||||
return CSSMin.compress(code);
|
* @author kjheimark <3
|
||||||
|
*/
|
||||||
|
private static String readFileAsString(String path) throws IOException {
|
||||||
|
BufferedReader bufferedReader = new BufferedReader(new FileReader(path));
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int c;
|
||||||
|
while ((c = bufferedReader.read()) >= 0 && c >= 0) {
|
||||||
|
sb.append((char) c);
|
||||||
}
|
}
|
||||||
|
return sb.toString();
|
||||||
private static String compressJs(String code, String debugPath) {
|
|
||||||
return JSMin.compressJs(code, debugPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,48 @@
|
|||||||
package j2html.tags;
|
package j2html.tags;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import j2html.attributes.Attr;
|
||||||
import j2html.attributes.Attribute;
|
import j2html.attributes.Attribute;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
public abstract class Tag<T extends Tag<T>> extends DomContent {
|
||||||
|
|
||||||
public abstract class Tag {
|
protected String tagName;
|
||||||
|
private ArrayList<Attribute> attributes;
|
||||||
|
|
||||||
protected String tag;
|
protected Tag(String tagName) {
|
||||||
protected ArrayList<Attribute> attributes;
|
this.tagName = tagName;
|
||||||
protected Tag parent;
|
this.attributes = new ArrayList<Attribute>();
|
||||||
|
|
||||||
protected Tag(String tagType) {
|
|
||||||
this.tag = tagType;
|
|
||||||
this.attributes = new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParent(Tag parent) {
|
public String getTagName() {
|
||||||
this.parent = parent;
|
return this.tagName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String renderOpenTag() {
|
||||||
|
StringBuilder sb = new StringBuilder("<").append(tagName);
|
||||||
|
for (Attribute attribute : attributes) {
|
||||||
|
sb.append(attribute.render());
|
||||||
|
}
|
||||||
|
sb.append(">");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String renderCloseTag() {
|
||||||
|
return "</" + tagName + ">";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an attribute on an element
|
* Sets an attribute on an element
|
||||||
*
|
*
|
||||||
* @param name the attribute
|
* @param name the attribute
|
||||||
* @param value the attribute value
|
* @param value the attribute value
|
||||||
*/
|
*/
|
||||||
public boolean setAttribute(String name, String value) {
|
boolean setAttribute(String name, String value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return attributes.add(new Attribute(name));
|
return attributes.add(new Attribute(name));
|
||||||
}
|
}
|
||||||
@@ -38,25 +55,110 @@ public abstract class Tag {
|
|||||||
return attributes.add(new Attribute(name, value));
|
return attributes.add(new Attribute(name, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String render() {
|
|
||||||
return renderOpenTag() + renderCloseTag();
|
/**
|
||||||
|
* Sets a custom attribute
|
||||||
|
*
|
||||||
|
* @param attribute the attribute name
|
||||||
|
* @param value the attribute value
|
||||||
|
* @return itself for easy chaining
|
||||||
|
*/
|
||||||
|
public T attr(String attribute, String value) {
|
||||||
|
setAttribute(attribute, value);
|
||||||
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a custom attribute without value
|
||||||
|
*
|
||||||
|
* @param attribute the attribute name
|
||||||
|
* @return itself for easy chaining
|
||||||
|
* @see Tag#attr(String, String)
|
||||||
|
*/
|
||||||
|
public T attr(String attribute) {
|
||||||
|
return attr(attribute, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call attr-method based on condition
|
||||||
|
* {@link #attr(String attribute, String value)}
|
||||||
|
*
|
||||||
|
* @param condition the condition
|
||||||
|
* @param attribute the attribute name
|
||||||
|
* @param value the attribute value
|
||||||
|
* @return itself for easy chaining
|
||||||
|
*/
|
||||||
|
public T condAttr(boolean condition, String attribute, String value) {
|
||||||
|
return (condition ? attr(attribute, value) : (T) this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public boolean equals(Object obj) {
|
||||||
return this.render();
|
if (obj == null || !(obj instanceof Tag)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ((Tag) obj).render().equals(this.render());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String renderOpenTag() {
|
|
||||||
String tagAttributes = "";
|
/**
|
||||||
for (Attribute attribute : attributes) {
|
* Convenience methods that call attr with predefined attributes
|
||||||
tagAttributes += attribute.render();
|
* @return itself for easy chaining
|
||||||
|
*/
|
||||||
|
|
||||||
|
public T withClasses(String... classes) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String s : classes) {
|
||||||
|
sb.append(s != null ? s : "").append(" ");
|
||||||
}
|
}
|
||||||
return "<" + tag + tagAttributes + ">";
|
return attr(Attr.CLASS, sb.toString().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String renderCloseTag() {
|
public T isAutoComplete() { return attr(Attr.AUTOCOMPLETE, null); }
|
||||||
return "</" + tag + ">";
|
public T isAutoFocus() { return attr(Attr.AUTOFOCUS, null); }
|
||||||
}
|
public T isHidden() { return attr(Attr.HIDDEN, null); }
|
||||||
|
public T isRequired() { return attr(Attr.REQUIRED, null); }
|
||||||
|
public T withAlt(String alt) { return attr(Attr.ALT, alt); }
|
||||||
|
public T withAction(String action) { return attr(Attr.ACTION, action); }
|
||||||
|
public T withCharset(String charset) { return attr(Attr.CHARSET, charset); }
|
||||||
|
public T withClass(String className) { return attr(Attr.CLASS, className); }
|
||||||
|
public T withContent(String content) { return attr(Attr.CONTENT, content); }
|
||||||
|
public T withHref(String href) { return attr(Attr.HREF, href); }
|
||||||
|
public T withId(String id) { return attr(Attr.ID, id); }
|
||||||
|
public T withData(String dataAttr, String value) { return attr(Attr.DATA + "-" + dataAttr, value); }
|
||||||
|
public T withMethod(String method) { return attr(Attr.METHOD, method); }
|
||||||
|
public T withName(String name) { return attr(Attr.NAME, name); }
|
||||||
|
public T withPlaceholder(String placeholder) { return attr(Attr.PLACEHOLDER, placeholder); }
|
||||||
|
public T withTarget(String target) { return attr(Attr.TARGET, target); }
|
||||||
|
public T withType(String type) { return attr(Attr.TYPE, type); }
|
||||||
|
public T withRel(String rel) { return attr(Attr.REL, rel); }
|
||||||
|
public T withRole(String role) { return attr(Attr.ROLE, role); }
|
||||||
|
public T withSrc(String src) { return attr(Attr.SRC, src); }
|
||||||
|
public T withStyle(String style) { return attr(Attr.STYLE, style); }
|
||||||
|
public T withValue(String value) { return attr(Attr.VALUE, value); }
|
||||||
|
|
||||||
|
public T withCondAutoComplete(boolean condition) { return condAttr(condition, Attr.AUTOCOMPLETE, null); }
|
||||||
|
public T withCondAutoFocus(boolean condition) { return condAttr(condition, Attr.AUTOFOCUS, null); }
|
||||||
|
public T withCondHidden(boolean condition) { return condAttr(condition, Attr.HIDDEN, null); }
|
||||||
|
public T withCondRequired(boolean condition) { return condAttr(condition, Attr.REQUIRED, null); }
|
||||||
|
public T withCondAlt(boolean condition, String alt) { return condAttr(condition, Attr.ALT, alt); }
|
||||||
|
public T withCondAction(boolean condition, String action) { return condAttr(condition, Attr.ACTION, action); }
|
||||||
|
public T withCharset(boolean condition, String charset) { return condAttr(condition, Attr.CHARSET, charset); }
|
||||||
|
public T withCondClass(boolean condition, String className) { return condAttr(condition, Attr.CLASS, className); }
|
||||||
|
public T withCondContent(boolean condition, String content) { return condAttr(condition, Attr.CONTENT, content); }
|
||||||
|
public T withCondHref(boolean condition, String href) { return condAttr(condition, Attr.HREF, href); }
|
||||||
|
public T withCondId(boolean condition, String id) { return condAttr(condition, Attr.ID, id); }
|
||||||
|
public T withCondData(boolean condition, String dataAttr, String value) { return condAttr(condition, Attr.DATA + "-" + dataAttr, value); }
|
||||||
|
public T withCondMethod(boolean condition, String method) { return condAttr(condition, Attr.METHOD, method); }
|
||||||
|
public T withCondName(boolean condition, String name) { return condAttr(condition, Attr.NAME, name); }
|
||||||
|
public T withCondPlaceholder(boolean condition, String placeholder) { return condAttr(condition, Attr.PLACEHOLDER, placeholder); }
|
||||||
|
public T withCondTarget(boolean condition, String target) { return condAttr(condition, Attr.TARGET, target); }
|
||||||
|
public T withCondType(boolean condition, String type) { return condAttr(condition, Attr.TYPE, type); }
|
||||||
|
public T withCondRel(boolean condition, String rel) { return condAttr(condition, Attr.REL, rel); }
|
||||||
|
public T withCondSrc(boolean condition, String src) { return condAttr(condition, Attr.SRC, src); }
|
||||||
|
public T withCondStyle(boolean condition, String style) { return condAttr(condition, Attr.STYLE, style); }
|
||||||
|
public T withCondValue(boolean condition, String value) { return condAttr(condition, Attr.VALUE, value); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
167
src/main/java/j2html/tags/TagCreatorCodeGenerator.java
Normal file
167
src/main/java/j2html/tags/TagCreatorCodeGenerator.java
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
package j2html.tags;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
class TagCreatorCodeGenerator {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("// EmptyTags, generated in " + TagCreatorCodeGenerator.class);
|
||||||
|
for (String tag : emptyTags()) {
|
||||||
|
String emptyA1 = "public static EmptyTag " + tag + "()";
|
||||||
|
String emptyA2 = "{ return new EmptyTag(\"" + tag + "\"); }";
|
||||||
|
// Attr shorthands
|
||||||
|
String emptyB1 = "public static EmptyTag " + tag + "(Attr.ShortForm shortAttr)";
|
||||||
|
String emptyB2 = "{ return Attr.addTo(new EmptyTag(\"" + tag + "\"), shortAttr); }";
|
||||||
|
// Print
|
||||||
|
System.out.println(String.format("%-80s%1s", emptyA1, emptyA2));
|
||||||
|
System.out.println(String.format("%-80s%1s", emptyB1, emptyB2));
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
System.out.println("// ContainerTags, generated in " + TagCreatorCodeGenerator.class);
|
||||||
|
for (String tag : containerTags()) {
|
||||||
|
String containerA1 = "public static ContainerTag " + tag + "()";
|
||||||
|
String containerA2 = "{ return new ContainerTag(\"" + tag + "\"); }";
|
||||||
|
String containerB1 = "public static ContainerTag " + tag + "(String text)";
|
||||||
|
String containerB2 = "{ return new ContainerTag(\"" + tag + "\").withText(text); }";
|
||||||
|
String containerC1 = "public static ContainerTag " + tag + "(DomContent... dc)";
|
||||||
|
String containerC2 = "{ return new ContainerTag(\"" + tag + "\").with(dc); }";
|
||||||
|
// Attr shorthands
|
||||||
|
String containerD1 = "public static ContainerTag " + tag + "(Attr.ShortForm shortAttr)";
|
||||||
|
String containerD2 = "{ return Attr.addTo(new ContainerTag(\"" + tag + "\"), shortAttr); }";
|
||||||
|
String containerE1 = "public static ContainerTag " + tag + "(Attr.ShortForm shortAttr, String text)";
|
||||||
|
String containerE2 = "{ return Attr.addTo(new ContainerTag(\"" + tag + "\").withText(text), shortAttr); }";
|
||||||
|
String containerF1 = "public static ContainerTag " + tag + "(Attr.ShortForm shortAttr, DomContent... dc)";
|
||||||
|
String containerF2 = "{ return Attr.addTo(new ContainerTag(\"" + tag + "\").with(dc), shortAttr); }";
|
||||||
|
// Print
|
||||||
|
System.out.println(String.format("%-80s%1s", containerA1, containerA2));
|
||||||
|
System.out.println(String.format("%-80s%1s", containerB1, containerB2));
|
||||||
|
System.out.println(String.format("%-80s%1s", containerC1, containerC2));
|
||||||
|
System.out.println(String.format("%-80s%1s", containerD1, containerD2));
|
||||||
|
System.out.println(String.format("%-80s%1s", containerE1, containerE2));
|
||||||
|
System.out.println(String.format("%-80s%1s", containerF1, containerF2));
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is a method that contains all ContainerTags, there is nothing below it
|
||||||
|
private static List<String> emptyTags() {
|
||||||
|
return Arrays.asList(
|
||||||
|
"area",
|
||||||
|
"base",
|
||||||
|
"br",
|
||||||
|
"col",
|
||||||
|
//"!DOCTYPE html",
|
||||||
|
"embed",
|
||||||
|
"hr",
|
||||||
|
"img",
|
||||||
|
"input",
|
||||||
|
"keygen",
|
||||||
|
"link",
|
||||||
|
"meta",
|
||||||
|
"param",
|
||||||
|
"source",
|
||||||
|
"track",
|
||||||
|
"wbr"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> containerTags() {
|
||||||
|
return Arrays.asList(
|
||||||
|
"a",
|
||||||
|
"abbr",
|
||||||
|
"address",
|
||||||
|
"article",
|
||||||
|
"aside",
|
||||||
|
"audio",
|
||||||
|
"b",
|
||||||
|
"bdi",
|
||||||
|
"bdo",
|
||||||
|
"blockquote",
|
||||||
|
"body",
|
||||||
|
"button",
|
||||||
|
"canvas",
|
||||||
|
"caption",
|
||||||
|
"cite",
|
||||||
|
"code",
|
||||||
|
"colgroup",
|
||||||
|
"datalist",
|
||||||
|
"dd",
|
||||||
|
"del",
|
||||||
|
"details",
|
||||||
|
"dfn",
|
||||||
|
"dialog",
|
||||||
|
"div",
|
||||||
|
"dl",
|
||||||
|
"dt",
|
||||||
|
"em",
|
||||||
|
"fieldset",
|
||||||
|
"figcaption",
|
||||||
|
"figure",
|
||||||
|
"footer",
|
||||||
|
"form",
|
||||||
|
"h1",
|
||||||
|
"h2",
|
||||||
|
"h3",
|
||||||
|
"h4",
|
||||||
|
"h5",
|
||||||
|
"h6",
|
||||||
|
"head",
|
||||||
|
"header",
|
||||||
|
"html",
|
||||||
|
"i",
|
||||||
|
"iframe",
|
||||||
|
"ins",
|
||||||
|
"kbd",
|
||||||
|
"label",
|
||||||
|
"legend",
|
||||||
|
"li",
|
||||||
|
"main",
|
||||||
|
"map",
|
||||||
|
"mark",
|
||||||
|
"menu",
|
||||||
|
"menuitem",
|
||||||
|
"meter",
|
||||||
|
"nav",
|
||||||
|
"noscript",
|
||||||
|
"object",
|
||||||
|
"ol",
|
||||||
|
"optgroup",
|
||||||
|
"option",
|
||||||
|
"output",
|
||||||
|
"p",
|
||||||
|
"pre",
|
||||||
|
"progress",
|
||||||
|
"q",
|
||||||
|
"rp",
|
||||||
|
"rt",
|
||||||
|
"ruby",
|
||||||
|
"s",
|
||||||
|
"samp",
|
||||||
|
"script",
|
||||||
|
"section",
|
||||||
|
"select",
|
||||||
|
"small",
|
||||||
|
"span",
|
||||||
|
"strong",
|
||||||
|
"style",
|
||||||
|
"sub",
|
||||||
|
"summary",
|
||||||
|
"sup",
|
||||||
|
"table",
|
||||||
|
"tbody",
|
||||||
|
"td",
|
||||||
|
"textarea",
|
||||||
|
"tfoot",
|
||||||
|
"th",
|
||||||
|
"thead",
|
||||||
|
"time",
|
||||||
|
"title",
|
||||||
|
"tr",
|
||||||
|
"u",
|
||||||
|
"ul",
|
||||||
|
"var",
|
||||||
|
"video"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +1,18 @@
|
|||||||
package j2html.tags;
|
package j2html.tags;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringEscapeUtils.*;
|
import j2html.Config;
|
||||||
|
|
||||||
public class Text extends Tag {
|
public class Text extends DomContent {
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
|
||||||
public Text(String text) {
|
public Text(String text) {
|
||||||
super(text);
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String render() {
|
public String render() {
|
||||||
return escapeHtml4(tag);
|
return Config.textEscaper.escape(text);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
package j2html.tags;
|
package j2html.tags;
|
||||||
|
|
||||||
public class UnescapedText extends Tag {
|
public class UnescapedText extends DomContent {
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
|
||||||
public UnescapedText(String text) {
|
public UnescapedText(String text) {
|
||||||
super(text);
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String render() {
|
public String render() {
|
||||||
return tag;
|
return text;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
/**
|
/**
|
||||||
* * CSSMin Copyright License Agreement (BSD License)
|
* * CSSMin Copyright License Agreement (BSD License)
|
||||||
*
|
* <p>
|
||||||
* Copyright (c) 2011-2014, Barry van Oudtshoorn
|
* Copyright (c) 2011-2014, Barry van Oudtshoorn
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
* <p>
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
*
|
* <p>
|
||||||
* - Redistributions of source code must retain the above
|
* - Redistributions of source code must retain the above
|
||||||
* copyright notice, this list of conditions and the
|
* copyright notice, this list of conditions and the
|
||||||
* following disclaimer.
|
* following disclaimer.
|
||||||
*
|
* <p>
|
||||||
* - Redistributions in binary form must reproduce the above
|
* - Redistributions in binary form must reproduce the above
|
||||||
* copyright notice, this list of conditions and the
|
* copyright notice, this list of conditions and the
|
||||||
* following disclaimer in the documentation and/or other
|
* following disclaimer in the documentation and/or other
|
||||||
* materials provided with the distribution.
|
* materials provided with the distribution.
|
||||||
*
|
* <p>
|
||||||
* - Neither the name of Barryvan nor the names of its
|
* - Neither the name of Barryvan nor the names of its
|
||||||
* contributors may be used to endorse or promote products
|
* contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior
|
* derived from this software without specific prior
|
||||||
* written permission.
|
* written permission.
|
||||||
*
|
* <p>
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
@@ -33,11 +33,11 @@
|
|||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
* <p>
|
||||||
* CSSMin takes in well-formed, human-readable CSS and reduces its size substantially.
|
* CSSMin takes in well-formed, human-readable CSS and reduces its size substantially.
|
||||||
* It removes unnecessary whitespace and comments, and orders the contents of CSS
|
* It removes unnecessary whitespace and comments, and orders the contents of CSS
|
||||||
* selectors alphabetically to enhance GZIP compression.
|
* selectors alphabetically to enhance GZIP compression.
|
||||||
*
|
* <p>
|
||||||
* Originally by Barry van Oudtshoorn, with bug reports, fixes, and contributions by
|
* Originally by Barry van Oudtshoorn, with bug reports, fixes, and contributions by
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Kevin de Groote</li>
|
* <li>Kevin de Groote</li>
|
||||||
@@ -53,21 +53,31 @@
|
|||||||
|
|
||||||
package j2html.utils;
|
package j2html.utils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedReader;
|
||||||
import java.util.*;
|
import java.io.StringReader;
|
||||||
import java.util.logging.*;
|
import java.util.ArrayList;
|
||||||
import java.util.regex.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
public class CSSMin {
|
public class CSSMin {
|
||||||
|
|
||||||
|
private CSSMin() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(CSSMin.class.getName());
|
private static final Logger LOG = Logger.getLogger(CSSMin.class.getName());
|
||||||
|
|
||||||
protected static boolean debugLogging = false;
|
static boolean debugLogging = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minify CSS from a reader to a printstream.
|
* Minify supplied CSS.
|
||||||
*
|
*
|
||||||
* @param input Where to read the CSS from
|
* @param input the CSS
|
||||||
|
* @return the compressed version
|
||||||
*/
|
*/
|
||||||
public static String compress(String input) {
|
public static String compress(String input) {
|
||||||
try {
|
try {
|
||||||
@@ -84,7 +94,9 @@ public class CSSMin {
|
|||||||
}
|
}
|
||||||
String s;
|
String s;
|
||||||
while ((s = br.readLine()) != null) {
|
while ((s = br.readLine()) != null) {
|
||||||
if (s.trim().equals("")) continue;
|
if (s.trim().equals("")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sb.append(s);
|
sb.append(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +124,7 @@ public class CSSMin {
|
|||||||
if (debugLogging) {
|
if (debugLogging) {
|
||||||
LOG.info("Parsing and processing selectors...");
|
LOG.info("Parsing and processing selectors...");
|
||||||
}
|
}
|
||||||
Vector<Selector> selectors = new Vector<>();
|
Vector<Selector> selectors = new Vector<Selector>();
|
||||||
n = 0;
|
n = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
for (int i = 0; i < sb.length(); i++) {
|
for (int i = 0; i < sb.length(); i++) {
|
||||||
@@ -178,7 +190,7 @@ class Selector {
|
|||||||
* @param selector The selector; for example, "div { border: solid 1px red; color: blue; }"
|
* @param selector The selector; for example, "div { border: solid 1px red; color: blue; }"
|
||||||
* @throws IncompleteSelectorException, UnterminatedSelectorException, EmptySelectorBodyException If the selector is incomplete and cannot be parsed.
|
* @throws IncompleteSelectorException, UnterminatedSelectorException, EmptySelectorBodyException If the selector is incomplete and cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public Selector(String selector) throws IncompleteSelectorException, UnterminatedSelectorException, EmptySelectorBodyException {
|
Selector(String selector) throws IncompleteSelectorException, UnterminatedSelectorException, EmptySelectorBodyException {
|
||||||
String[] parts = selector.split("\\{"); // We have to escape the { with a \ for the regex, which itself requires escaping for the string. Sigh.
|
String[] parts = selector.split("\\{"); // We have to escape the { with a \ for the regex, which itself requires escaping for the string. Sigh.
|
||||||
if (parts.length < 2) {
|
if (parts.length < 2) {
|
||||||
throw new IncompleteSelectorException(selector);
|
throw new IncompleteSelectorException(selector);
|
||||||
@@ -189,10 +201,9 @@ class Selector {
|
|||||||
// Simplify combinators
|
// Simplify combinators
|
||||||
this.selector = this.selector.replaceAll("\\s?(\\+|~|,|=|~=|\\^=|\\$=|\\*=|\\|=|>)\\s?", "$1");
|
this.selector = this.selector.replaceAll("\\s?(\\+|~|,|=|~=|\\^=|\\$=|\\*=|\\|=|>)\\s?", "$1");
|
||||||
|
|
||||||
|
|
||||||
// We're dealing with a nested property, eg @-webkit-keyframes
|
// We're dealing with a nested property, eg @-webkit-keyframes
|
||||||
if (parts.length > 2) {
|
if (parts.length > 2) {
|
||||||
this.subSelectors = new Vector<>();
|
this.subSelectors = new Vector<Selector>();
|
||||||
parts = selector.split("(\\s*\\{\\s*)|(\\s*\\}\\s*)");
|
parts = selector.split("(\\s*\\{\\s*)|(\\s*\\}\\s*)");
|
||||||
for (int i = 1; i < parts.length; i += 2) {
|
for (int i = 1; i < parts.length; i += 2) {
|
||||||
parts[i] = parts[i].trim();
|
parts[i] = parts[i].trim();
|
||||||
@@ -253,7 +264,7 @@ class Selector {
|
|||||||
* @return An array of properties parsed from this selector.
|
* @return An array of properties parsed from this selector.
|
||||||
*/
|
*/
|
||||||
private ArrayList<Property> parseProperties(String contents) {
|
private ArrayList<Property> parseProperties(String contents) {
|
||||||
ArrayList<String> parts = new ArrayList<>();
|
ArrayList<String> parts = new ArrayList<String>();
|
||||||
boolean bInsideString = false,
|
boolean bInsideString = false,
|
||||||
bInsideURL = false;
|
bInsideURL = false;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
@@ -266,17 +277,23 @@ class Selector {
|
|||||||
} else if (contents.charAt(i) == '"') {
|
} else if (contents.charAt(i) == '"') {
|
||||||
bInsideString = true;
|
bInsideString = true;
|
||||||
} else if (contents.charAt(i) == '(') {
|
} else if (contents.charAt(i) == '(') {
|
||||||
if ((i - 3) > 0 && "url".equals(contents.substring(i - 3, i))) bInsideURL = true;
|
if ((i - 3) > 0 && "url".equals(contents.substring(i - 3, i))) {
|
||||||
|
bInsideURL = true;
|
||||||
|
}
|
||||||
} else if (contents.charAt(i) == ';') {
|
} else if (contents.charAt(i) == ';') {
|
||||||
substr = contents.substring(j, i);
|
substr = contents.substring(j, i);
|
||||||
if (!(substr.trim().equals(""))) parts.add(substr);
|
if (!(substr.trim().equals(""))) {
|
||||||
|
parts.add(substr);
|
||||||
|
}
|
||||||
j = i + 1;
|
j = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
substr = contents.substring(j, contents.length());
|
substr = contents.substring(j, contents.length());
|
||||||
if (!(substr.trim().equals(""))) parts.add(substr);
|
if (!(substr.trim().equals(""))) {
|
||||||
|
parts.add(substr);
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<Property> results = new ArrayList<>();
|
ArrayList<Property> results = new ArrayList<Property>();
|
||||||
for (String part : parts) {
|
for (String part : parts) {
|
||||||
try {
|
try {
|
||||||
results.add(new Property(part));
|
results.add(new Property(part));
|
||||||
@@ -302,8 +319,8 @@ class Property implements Comparable<Property> {
|
|||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(Property.class.getName());
|
private static final Logger LOG = Logger.getLogger(Property.class.getName());
|
||||||
|
|
||||||
protected String property;
|
private String property;
|
||||||
protected Part[] parts;
|
private Part[] parts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Property using the supplied strings. Parses out the values of the property selector.
|
* Creates a new Property using the supplied strings. Parses out the values of the property selector.
|
||||||
@@ -311,10 +328,10 @@ class Property implements Comparable<Property> {
|
|||||||
* @param property The property; for example, "border: solid 1px red;" or "-moz-box-shadow: 3px 3px 3px rgba(255, 255, 0, 0.5);".
|
* @param property The property; for example, "border: solid 1px red;" or "-moz-box-shadow: 3px 3px 3px rgba(255, 255, 0, 0.5);".
|
||||||
* @throws IncompletePropertyException If the property is incomplete and cannot be parsed.
|
* @throws IncompletePropertyException If the property is incomplete and cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public Property(String property) throws IncompletePropertyException {
|
Property(String property) throws IncompletePropertyException {
|
||||||
try {
|
try {
|
||||||
// Parse the property.
|
// Parse the property.
|
||||||
ArrayList<String> parts = new ArrayList<>();
|
ArrayList<String> parts = new ArrayList<String>();
|
||||||
boolean bCanSplit = true;
|
boolean bCanSplit = true;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
String substr;
|
String substr;
|
||||||
@@ -326,14 +343,18 @@ class Property implements Comparable<Property> {
|
|||||||
bCanSplit = (property.charAt(i) == '"');
|
bCanSplit = (property.charAt(i) == '"');
|
||||||
} else if (property.charAt(i) == '"') {
|
} else if (property.charAt(i) == '"') {
|
||||||
bCanSplit = false;
|
bCanSplit = false;
|
||||||
} else if (property.charAt(i) == ':' && parts.size() < 1) {
|
} else if (property.charAt(i) == ':' && parts.isEmpty()) {
|
||||||
substr = property.substring(j, i);
|
substr = property.substring(j, i);
|
||||||
if (!(substr.trim().equals(""))) parts.add(substr);
|
if (!(substr.trim().equals(""))) {
|
||||||
|
parts.add(substr);
|
||||||
|
}
|
||||||
j = i + 1;
|
j = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
substr = property.substring(j, property.length());
|
substr = property.substring(j, property.length());
|
||||||
if (!(substr.trim().equals(""))) parts.add(substr);
|
if (!(substr.trim().equals(""))) {
|
||||||
|
parts.add(substr);
|
||||||
|
}
|
||||||
if (parts.size() < 2) {
|
if (parts.size() < 2) {
|
||||||
throw new IncompletePropertyException(property);
|
throw new IncompletePropertyException(property);
|
||||||
}
|
}
|
||||||
@@ -375,24 +396,17 @@ class Property implements Comparable<Property> {
|
|||||||
*/
|
*/
|
||||||
public int compareTo(Property other) {
|
public int compareTo(Property other) {
|
||||||
// We can't just use String.compareTo(), because we need to sort properties that have hack prefixes last -- eg, *display should come after display.
|
// We can't just use String.compareTo(), because we need to sort properties that have hack prefixes last -- eg, *display should come after display.
|
||||||
String thisProp = this.property;
|
return sort(this.property).compareTo(sort(other.property));
|
||||||
String thatProp = other.property;
|
}
|
||||||
|
|
||||||
|
private String sort(String thisProp) {
|
||||||
if (thisProp.charAt(0) == '-') {
|
if (thisProp.charAt(0) == '-') {
|
||||||
thisProp = thisProp.substring(1);
|
thisProp = thisProp.substring(1);
|
||||||
thisProp = thisProp.substring(thisProp.indexOf('-') + 1);
|
thisProp = thisProp.substring(thisProp.indexOf('-') + 1);
|
||||||
} else if (thisProp.charAt(0) < 65) {
|
} else if (thisProp.charAt(0) < 65) {
|
||||||
thisProp = thisProp.substring(1);
|
thisProp = thisProp.substring(1);
|
||||||
}
|
}
|
||||||
|
return thisProp;
|
||||||
if (thatProp.charAt(0) == '-') {
|
|
||||||
thatProp = thatProp.substring(1);
|
|
||||||
thatProp = thatProp.substring(thatProp.indexOf('-') + 1);
|
|
||||||
} else if (thatProp.charAt(0) < 65) {
|
|
||||||
thatProp = thatProp.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return thisProp.compareTo(thatProp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -456,8 +470,8 @@ class Property implements Comparable<Property> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Part {
|
class Part {
|
||||||
String contents;
|
private String contents;
|
||||||
String property;
|
private String property;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new property by parsing the given string.
|
* Create a new property by parsing the given string.
|
||||||
@@ -465,7 +479,7 @@ class Part {
|
|||||||
* @param contents The string to parse.
|
* @param contents The string to parse.
|
||||||
* @throws Exception If the part cannot be parsed.
|
* @throws Exception If the part cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public Part(String contents, String property) throws Exception {
|
Part(String contents, String property) throws Exception {
|
||||||
// Many of these regular expressions are adapted from those used in the YUI CSS Compressor.
|
// Many of these regular expressions are adapted from those used in the YUI CSS Compressor.
|
||||||
|
|
||||||
// For simpler regexes.
|
// For simpler regexes.
|
||||||
@@ -486,9 +500,15 @@ class Part {
|
|||||||
this.contents = this.contents.trim();
|
this.contents = this.contents.trim();
|
||||||
|
|
||||||
// Simplify multiple zeroes
|
// Simplify multiple zeroes
|
||||||
if (this.contents.equals("0 0 0 0")) this.contents = "0";
|
if (this.contents.equals("0 0 0 0")) {
|
||||||
if (this.contents.equals("0 0 0")) this.contents = "0";
|
this.contents = "0";
|
||||||
if (this.contents.equals("0 0")) this.contents = "0";
|
}
|
||||||
|
if (this.contents.equals("0 0 0")) {
|
||||||
|
this.contents = "0";
|
||||||
|
}
|
||||||
|
if (this.contents.equals("0 0")) {
|
||||||
|
this.contents = "0";
|
||||||
|
}
|
||||||
|
|
||||||
// Simplify multiple-parameter properties
|
// Simplify multiple-parameter properties
|
||||||
simplifyParameters();
|
simplifyParameters();
|
||||||
@@ -505,32 +525,28 @@ class Part {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void simplifyParameters() {
|
private void simplifyParameters() {
|
||||||
if (this.property.equals("background-size")) return;
|
if (this.property.equals("background-size")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder newContents = new StringBuilder();
|
StringBuilder newContents = new StringBuilder();
|
||||||
|
|
||||||
String[] params = this.contents.split(" ");
|
String[] params = this.contents.split(" ");
|
||||||
if (params.length == 4) {
|
if (params.length == 4 && params[1].equalsIgnoreCase(params[3])) {
|
||||||
// We can drop off the fourth item if the second and fourth items match
|
// We can drop off the fourth item if the second and fourth items match
|
||||||
// ie turn 3px 0 3px 0 into 3px 0 3px
|
// ie turn 3px 0 3px 0 into 3px 0 3px
|
||||||
if (params[1].equalsIgnoreCase(params[3])) {
|
|
||||||
params = Arrays.copyOf(params, 3);
|
params = Arrays.copyOf(params, 3);
|
||||||
}
|
}
|
||||||
}
|
if (params.length == 3 && params[0].equalsIgnoreCase(params[2])) {
|
||||||
if (params.length == 3) {
|
|
||||||
// We can drop off the third item if the first and third items match
|
// We can drop off the third item if the first and third items match
|
||||||
// ie turn 3px 0 3px into 3px 0
|
// ie turn 3px 0 3px into 3px 0
|
||||||
if (params[0].equalsIgnoreCase(params[2])) {
|
|
||||||
params = Arrays.copyOf(params, 2);
|
params = Arrays.copyOf(params, 2);
|
||||||
}
|
}
|
||||||
}
|
if (params.length == 2 && params[0].equalsIgnoreCase(params[1])) {
|
||||||
if (params.length == 2) {
|
|
||||||
// We can drop off the second item if the first and second items match
|
// We can drop off the second item if the first and second items match
|
||||||
// ie turn 3px 3px into 3px
|
// ie turn 3px 3px into 3px
|
||||||
if (params[0].equalsIgnoreCase(params[1])) {
|
|
||||||
params = Arrays.copyOf(params, 1);
|
params = Arrays.copyOf(params, 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (String param : params) {
|
for (String param : params) {
|
||||||
newContents.append(param).append(" ");
|
newContents.append(param).append(" ");
|
||||||
@@ -541,7 +557,9 @@ class Part {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void simplifyFontWeights() {
|
private void simplifyFontWeights() {
|
||||||
if (!this.property.equals("font-weight")) return;
|
if (!this.property.equals("font-weight")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String lcContents = this.contents.toLowerCase();
|
String lcContents = this.contents.toLowerCase();
|
||||||
|
|
||||||
@@ -615,14 +633,16 @@ class Part {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnterminatedCommentException extends Exception {}
|
class UnterminatedCommentException extends Exception {
|
||||||
|
}
|
||||||
|
|
||||||
class UnbalancedBracesException extends Exception {}
|
class UnbalancedBracesException extends Exception {
|
||||||
|
}
|
||||||
|
|
||||||
class IncompletePropertyException extends Exception {
|
class IncompletePropertyException extends Exception {
|
||||||
String message = null;
|
private final String message;
|
||||||
|
|
||||||
public IncompletePropertyException(String message) {
|
IncompletePropertyException(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -632,9 +652,9 @@ class IncompletePropertyException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class EmptySelectorBodyException extends Exception {
|
class EmptySelectorBodyException extends Exception {
|
||||||
String message = null;
|
private final String message;
|
||||||
|
|
||||||
public EmptySelectorBodyException(String message) {
|
EmptySelectorBodyException(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,9 +664,9 @@ class EmptySelectorBodyException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UnterminatedSelectorException extends Exception {
|
class UnterminatedSelectorException extends Exception {
|
||||||
String message = null;
|
private final String message;
|
||||||
|
|
||||||
public UnterminatedSelectorException(String message) {
|
UnterminatedSelectorException(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,9 +676,9 @@ class UnterminatedSelectorException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IncompleteSelectorException extends Exception {
|
class IncompleteSelectorException extends Exception {
|
||||||
String message = null;
|
private final String message;
|
||||||
|
|
||||||
public IncompleteSelectorException(String message) {
|
IncompleteSelectorException(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,305 @@
|
|||||||
package j2html.utils;
|
package j2html.utils;
|
||||||
|
/*
|
||||||
|
* JSMin.java 2006-02-13
|
||||||
|
*
|
||||||
|
* Copyright (c) 2006 John Reilly (www.inconspicuous.org)
|
||||||
|
*
|
||||||
|
* This work is a translation from C to Java of jsmin.c published by
|
||||||
|
* Douglas Crockford. Permission is hereby granted to use the Java
|
||||||
|
* version under the same conditions as the jsmin.c on which it is
|
||||||
|
* based.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* jsmin.c 2003-04-21
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* The Software shall be used for Good, not Evil.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// package org.inconspicuous.jsmin;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PushbackInputStream;
|
||||||
|
|
||||||
import com.google.javascript.jscomp.*;
|
|
||||||
import com.google.javascript.jscomp.Compiler;
|
|
||||||
|
|
||||||
public class JSMin {
|
public class JSMin {
|
||||||
|
|
||||||
public static String compressJs(String code, String sourcePath) {
|
/**
|
||||||
com.google.javascript.jscomp.Compiler compiler = new Compiler();
|
* Compress a JS-string
|
||||||
CompilerOptions options = new CompilerOptions();
|
*
|
||||||
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
|
* @param code the js-code you want to compress
|
||||||
SourceFile extern = SourceFile.fromCode("externs.js", "");
|
* @return the compressed code
|
||||||
SourceFile input = SourceFile.fromCode(sourcePath, code);
|
*/
|
||||||
compiler.compile(extern, input, options);
|
public static String compressJs(String code) {
|
||||||
return compiler.toSource();
|
InputStream inStream = new ByteArrayInputStream(code.getBytes());
|
||||||
|
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||||
|
JSMin jsmin = new JSMin(inStream, outStream);
|
||||||
|
try {
|
||||||
|
jsmin.jsmin();
|
||||||
|
return outStream.toString().trim();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int EOF = -1;
|
||||||
|
|
||||||
|
private PushbackInputStream in;
|
||||||
|
private OutputStream out;
|
||||||
|
|
||||||
|
private int theA;
|
||||||
|
private int theB;
|
||||||
|
|
||||||
|
private JSMin(InputStream in, OutputStream out) {
|
||||||
|
this.in = new PushbackInputStream(in);
|
||||||
|
this.out = out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* isAlphanum -- return true if the character is a letter, digit,
|
||||||
|
* underscore, dollar sign, or non-ASCII character.
|
||||||
|
*/
|
||||||
|
private static boolean isAlphanum(int c) {
|
||||||
|
return ((c >= 'a' && c <= 'z') ||
|
||||||
|
(c >= '0' && c <= '9') ||
|
||||||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
|
c == '_' ||
|
||||||
|
c == '$' ||
|
||||||
|
c == '\\' ||
|
||||||
|
c > 126);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get -- return the next character from stdin. Watch out for lookahead. If
|
||||||
|
* the character is a control character, translate it to a space or
|
||||||
|
* linefeed.
|
||||||
|
*/
|
||||||
|
private int get() throws IOException {
|
||||||
|
int c = in.read();
|
||||||
|
|
||||||
|
if (c >= ' ' || c == '\n' || c == EOF) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == '\r') {
|
||||||
|
return '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the next character without getting it.
|
||||||
|
*/
|
||||||
|
private int peek() throws IOException {
|
||||||
|
int lookaheadChar = in.read();
|
||||||
|
in.unread(lookaheadChar);
|
||||||
|
return lookaheadChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* next -- get the next character, excluding comments. peek() is used to see
|
||||||
|
* if a '/' is followed by a '/' or '*'.
|
||||||
|
*/
|
||||||
|
private int next() throws IOException, UnterminatedCommentException {
|
||||||
|
int c = get();
|
||||||
|
if (c == '/') {
|
||||||
|
switch (peek()) {
|
||||||
|
case '/':
|
||||||
|
for (; ; ) {
|
||||||
|
c = get();
|
||||||
|
if (c <= '\n') {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case '*':
|
||||||
|
get();
|
||||||
|
for (; ; ) {
|
||||||
|
switch (get()) {
|
||||||
|
case '*':
|
||||||
|
if (peek() == '/') {
|
||||||
|
get();
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EOF:
|
||||||
|
throw new UnterminatedCommentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* action -- do something! What you do is determined by the argument: 1
|
||||||
|
* Output A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B.
|
||||||
|
* (Delete A). 3 Get the next B. (Delete B). action treats a string as a
|
||||||
|
* single character. Wow! action recognizes a regular expression if it is
|
||||||
|
* preceded by ( or , or =.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private void action(int d) throws IOException, UnterminatedRegExpLiteralException,
|
||||||
|
UnterminatedCommentException, UnterminatedStringLiteralException {
|
||||||
|
switch (d) {
|
||||||
|
case 1:
|
||||||
|
out.write(theA);
|
||||||
|
case 2:
|
||||||
|
theA = theB;
|
||||||
|
|
||||||
|
if (theA == '\'' || theA == '"') {
|
||||||
|
for (; ; ) {
|
||||||
|
out.write(theA);
|
||||||
|
theA = get();
|
||||||
|
if (theA == theB) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (theA <= '\n') {
|
||||||
|
throw new UnterminatedStringLiteralException();
|
||||||
|
}
|
||||||
|
if (theA == '\\') {
|
||||||
|
out.write(theA);
|
||||||
|
theA = get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
theB = next();
|
||||||
|
if (theB == '/' && (theA == '(' || theA == ',' || theA == '=')) {
|
||||||
|
out.write(theA);
|
||||||
|
out.write(theB);
|
||||||
|
for (; ; ) {
|
||||||
|
theA = get();
|
||||||
|
if (theA == '/') {
|
||||||
|
break;
|
||||||
|
} else if (theA == '\\') {
|
||||||
|
out.write(theA);
|
||||||
|
theA = get();
|
||||||
|
} else if (theA <= '\n') {
|
||||||
|
throw new UnterminatedRegExpLiteralException();
|
||||||
|
}
|
||||||
|
out.write(theA);
|
||||||
|
}
|
||||||
|
theB = next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* jsmin -- Copy the input to the output, deleting the characters which are
|
||||||
|
* insignificant to JavaScript. Comments will be removed. Tabs will be
|
||||||
|
* replaced with spaces. Carriage returns will be replaced with linefeeds.
|
||||||
|
* Most spaces and linefeeds will be removed.
|
||||||
|
*/
|
||||||
|
public void jsmin() throws IOException, UnterminatedRegExpLiteralException, UnterminatedCommentException, UnterminatedStringLiteralException {
|
||||||
|
theA = '\n';
|
||||||
|
action(3);
|
||||||
|
while (theA != EOF) {
|
||||||
|
switch (theA) {
|
||||||
|
case ' ':
|
||||||
|
if (isAlphanum(theB)) {
|
||||||
|
action(1);
|
||||||
|
} else {
|
||||||
|
action(2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
switch (theB) {
|
||||||
|
case '{':
|
||||||
|
case '[':
|
||||||
|
case '(':
|
||||||
|
case '+':
|
||||||
|
case '-':
|
||||||
|
action(1);
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
action(3);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (isAlphanum(theB)) {
|
||||||
|
action(1);
|
||||||
|
} else {
|
||||||
|
action(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
switch (theB) {
|
||||||
|
case ' ':
|
||||||
|
if (isAlphanum(theA)) {
|
||||||
|
action(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
action(3);
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
switch (theA) {
|
||||||
|
case '}':
|
||||||
|
case ']':
|
||||||
|
case ')':
|
||||||
|
case '+':
|
||||||
|
case '-':
|
||||||
|
case '"':
|
||||||
|
case '\'':
|
||||||
|
action(1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (isAlphanum(theA)) {
|
||||||
|
action(1);
|
||||||
|
} else {
|
||||||
|
action(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
action(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UnterminatedCommentException extends Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UnterminatedStringLiteralException extends Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UnterminatedRegExpLiteralException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
36
src/main/java/j2html/utils/SimpleEscaper.java
Normal file
36
src/main/java/j2html/utils/SimpleEscaper.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package j2html.utils;
|
||||||
|
|
||||||
|
public class SimpleEscaper implements TextEscaper {
|
||||||
|
|
||||||
|
public String escape(String s) {
|
||||||
|
if (s == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
StringBuilder escapedText = new StringBuilder();
|
||||||
|
char currentChar;
|
||||||
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
currentChar = s.charAt(i);
|
||||||
|
switch (currentChar) {
|
||||||
|
case '<':
|
||||||
|
escapedText.append("<");
|
||||||
|
break;
|
||||||
|
case '>':
|
||||||
|
escapedText.append(">");
|
||||||
|
break;
|
||||||
|
case '&':
|
||||||
|
escapedText.append("&");
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
escapedText.append(""");
|
||||||
|
break;
|
||||||
|
case '\'':
|
||||||
|
escapedText.append("'");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
escapedText.append(currentChar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return escapedText.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
7
src/main/java/j2html/utils/TextEscaper.java
Normal file
7
src/main/java/j2html/utils/TextEscaper.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package j2html.utils;
|
||||||
|
|
||||||
|
public interface TextEscaper {
|
||||||
|
|
||||||
|
String escape(String text);
|
||||||
|
|
||||||
|
}
|
||||||
7
src/test/files/test.css
Normal file
7
src/test/files/test.css
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
body {
|
||||||
|
background: goldenrod;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
3
src/test/files/test.html
Normal file
3
src/test/files/test.html
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<body>
|
||||||
|
Any content
|
||||||
|
</body>
|
||||||
6
src/test/files/test.js
Normal file
6
src/test/files/test.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
(function () {
|
||||||
|
var test = 5;
|
||||||
|
var tast = 10;
|
||||||
|
var testTast = test + tast;
|
||||||
|
console.log(testTast);
|
||||||
|
})();
|
||||||
49
src/test/java/j2html/PerformanceTest.java
Normal file
49
src/test/java/j2html/PerformanceTest.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package j2html;
|
||||||
|
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import j2html.utils.SimpleEscaper;
|
||||||
|
|
||||||
|
public class PerformanceTest {
|
||||||
|
|
||||||
|
private String shortTestString = "<body>\n"
|
||||||
|
+ " <h1 class=\"example\">Heading!</h1>\n"
|
||||||
|
+ " <img src=\"img/hello.png\">\n"
|
||||||
|
+ "</body>";
|
||||||
|
|
||||||
|
// syntax-highlighted getting started example from j2html.com:
|
||||||
|
private String longTestString =
|
||||||
|
"<pre class=\" language-java\"><code class=\" language-java\"><span class=\"token keyword\">import</span> <span class=\"token keyword\">static</span> j2html<span class=\"token punctuation\">.</span>TagCreator<span class=\"token punctuation\">.</span>*<span class=\"token punctuation\">;</span>\n"
|
||||||
|
+ "\n"
|
||||||
|
+ "<span class=\"token keyword\">public</span> <span class=\"token keyword\">class</span> <span class=\"token class-name\">Main</span> <span class=\"token punctuation\">{</span>\n"
|
||||||
|
+ " <span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token keyword\">void</span> <span class=\"token function\">main<span class=\"token punctuation\">(</span></span>String<span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> args<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n"
|
||||||
|
+ " <span class=\"token function\">body<span class=\"token punctuation\">(</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">with<span class=\"token punctuation\">(</span></span>\n"
|
||||||
|
+ " <span class=\"token function\">h1<span class=\"token punctuation\">(</span></span><span class=\"token string\">\"Heading!\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">withClass<span class=\"token punctuation\">(</span></span><span class=\"token string\">\"example\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\n"
|
||||||
|
+ " <span class=\"token function\">img<span class=\"token punctuation\">(</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">withSrc<span class=\"token punctuation\">(</span></span><span class=\"token string\">\"img/hello.png\"</span><span class=\"token punctuation\">)</span>\n"
|
||||||
|
+ " <span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">render<span class=\"token punctuation\">(</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n"
|
||||||
|
+ " <span class=\"token punctuation\">}</span>\n"
|
||||||
|
+ "<span class=\"token punctuation\">}</span>\n"
|
||||||
|
+ "</code></pre>";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_escaper_performnce() throws Exception {
|
||||||
|
timeEscaper("SimpleEscaper#short", () -> new SimpleEscaper().escape(shortTestString));
|
||||||
|
timeEscaper("SimpleEscaper#long", () -> new SimpleEscaper().escape(longTestString));
|
||||||
|
timeEscaper("ApacheEscaper#short", () -> StringEscapeUtils.escapeHtml4(shortTestString));
|
||||||
|
timeEscaper("ApacheEscaper#long", () -> StringEscapeUtils.escapeHtml4(longTestString));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timeEscaper(String name, Callable escaper) throws Exception {
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
escaper.call();
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long durationMs = (endTime - startTime) / 1000000;
|
||||||
|
System.out.println(String.format("%-21s%s", name + ":", +durationMs + "ms"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
src/test/java/j2html/TextEscaperTest.java
Normal file
40
src/test/java/j2html/TextEscaperTest.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package j2html;
|
||||||
|
|
||||||
|
import j2html.utils.SimpleEscaper;
|
||||||
|
import j2html.utils.TextEscaper;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
public class TextEscaperTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTextEscaper() throws Exception {
|
||||||
|
assertThat("default text escaper is SimpleEscaper",
|
||||||
|
Config.textEscaper, is(instanceOf(SimpleEscaper.class)));
|
||||||
|
|
||||||
|
String expected = "<div></div>";
|
||||||
|
assertThat("default text escaper works",
|
||||||
|
Config.textEscaper.escape("<div></div>"), is(expected));
|
||||||
|
|
||||||
|
Config.textEscaper = new NoOpEscaper();
|
||||||
|
assertThat("user can change text escaper implementation",
|
||||||
|
Config.textEscaper, is(instanceOf(NoOpEscaper.class)));
|
||||||
|
|
||||||
|
expected = "<div></div>";
|
||||||
|
assertThat("user provided text escaper actually works",
|
||||||
|
Config.textEscaper.escape("<div></div>"), is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class NoOpEscaper implements TextEscaper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escape(String text) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
61
src/test/java/j2html/attributes/AttrShortFormTest.java
Normal file
61
src/test/java/j2html/attributes/AttrShortFormTest.java
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package j2html.attributes;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static j2html.TagCreator.*;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
public class AttrShortFormTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addTo_emptyTag() throws Exception {
|
||||||
|
String expected = "<input id=\"some-id\" class=\"some-class\">";
|
||||||
|
String actual = input(attrs("#some-id.some-class")).render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addTo_containerTag() throws Exception {
|
||||||
|
String expected = "<div id=\"some-id\" class=\"some-class\"></div>";
|
||||||
|
String actual = div(attrs("#some-id.some-class")).render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addTo_justId() throws Exception {
|
||||||
|
String expected = "<div id=\"some-id\"></div>";
|
||||||
|
String actual = div(attrs("#some-id")).render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addTo_justClass() throws Exception {
|
||||||
|
String expected = "<div class=\"some-class\"></div>";
|
||||||
|
String actual = div(attrs(".some-class")).render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addTo_addTwoClasses() throws Exception {
|
||||||
|
String expected = "<div class=\"some-class some-other-class\"></div>";
|
||||||
|
String actual = div(attrs(".some-class.some-other-class")).render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void addTo_stringWithoutIdOrClass() throws Exception {
|
||||||
|
div(attrs("some-class")).render();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void addTo_stringWithTwoIds() throws Exception {
|
||||||
|
div(attrs("#id1#id2")).render();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void addTo_stringWithStupidlyPlacedId() throws Exception {
|
||||||
|
div(attrs("id1#id2")).render();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,30 +1,32 @@
|
|||||||
package j2html.attributes;
|
package j2html.attributes;
|
||||||
|
|
||||||
import j2html.tags.ContainerTag;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import j2html.tags.ContainerTag;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class AttributeTest {
|
public class AttributeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRender() throws Exception {
|
public void testRender() throws Exception {
|
||||||
Attribute attributeWithValue = new Attribute("href", "http://example.com");
|
Attribute attributeWithValue = new Attribute("href", "http://example.com");
|
||||||
assertEquals(attributeWithValue.render(), " href=\"http://example.com\"");
|
assertThat(attributeWithValue.render(), is(" href=\"http://example.com\""));
|
||||||
|
|
||||||
Attribute attribute = new Attribute("required", null);
|
Attribute attribute = new Attribute("required", null);
|
||||||
assertEquals(attribute.render(), " required");
|
assertThat(attribute.render(), is(" required"));
|
||||||
|
|
||||||
Attribute nullAttribute = new Attribute(null, null);
|
Attribute nullAttribute = new Attribute(null, null);
|
||||||
assertEquals(nullAttribute.render(), "");
|
assertThat(nullAttribute.render(), is(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetAttribute() throws Exception {
|
public void testSetAttribute() throws Exception {
|
||||||
ContainerTag testTag = new ContainerTag("a");
|
ContainerTag testTag = new ContainerTag("a");
|
||||||
testTag.setAttribute("href", "http://example.com");
|
testTag.attr("href", "http://example.com");
|
||||||
testTag.setAttribute("href", "http://example.org");
|
testTag.attr("href", "http://example.org");
|
||||||
assertEquals(testTag.render(), "<a href=\"http://example.org\"></a>");
|
assertThat(testTag.render(), is("<a href=\"http://example.org\"></a>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,27 @@ package j2html.tags;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static j2html.TagCreator.*;
|
import j2html.attributes.Attr;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
import static j2html.TagCreator.a;
|
||||||
|
import static j2html.TagCreator.body;
|
||||||
|
import static j2html.TagCreator.button;
|
||||||
|
import static j2html.TagCreator.div;
|
||||||
|
import static j2html.TagCreator.document;
|
||||||
|
import static j2html.TagCreator.footer;
|
||||||
|
import static j2html.TagCreator.h1;
|
||||||
|
import static j2html.TagCreator.h2;
|
||||||
|
import static j2html.TagCreator.head;
|
||||||
|
import static j2html.TagCreator.header;
|
||||||
|
import static j2html.TagCreator.html;
|
||||||
|
import static j2html.TagCreator.iff;
|
||||||
|
import static j2html.TagCreator.input;
|
||||||
|
import static j2html.TagCreator.main;
|
||||||
|
import static j2html.TagCreator.script;
|
||||||
|
import static j2html.TagCreator.text;
|
||||||
|
import static j2html.TagCreator.title;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
|
||||||
public class ComplexRenderTest {
|
public class ComplexRenderTest {
|
||||||
|
|
||||||
@@ -17,20 +36,52 @@ public class ComplexRenderTest {
|
|||||||
),
|
),
|
||||||
body().with(
|
body().with(
|
||||||
header().with(
|
header().with(
|
||||||
h1("Test Header")
|
h1().with(
|
||||||
|
text("Test Header "),
|
||||||
|
a("with link").withHref("http://example.com"),
|
||||||
|
text(".")
|
||||||
|
)
|
||||||
),
|
),
|
||||||
main().with(
|
main().with(
|
||||||
h2("Test Form"),
|
h2("Test Form"),
|
||||||
div().with(
|
div().with(
|
||||||
input().withType("email").withName("email").withPlaceholder("Email"),
|
input().withType("email").withName("email").withPlaceholder("Email"),
|
||||||
input().withType("password").withName("password").withPlaceholder("Password")
|
input().withType("password").withName("password").withPlaceholder("Password")
|
||||||
).condWith(USER_SHOULD_LOG_IN,
|
).condWith(USER_SHOULD_LOG_IN, button().withType("submit").withText("Login")
|
||||||
button().withType("submit").withText("Login")
|
).condWith(USER_SHOULD_SIGN_UP, button().withType("submit").withText("Signup"))
|
||||||
).condWith(USER_SHOULD_SIGN_UP,
|
),
|
||||||
button().withType("submit").withText("Signup")
|
footer().attr(Attr.CLASS, "footer").condAttr(1 == 1, Attr.ID, "id").withText("Test Footer"),
|
||||||
|
script().withSrc("/testScript.js")
|
||||||
|
)
|
||||||
|
).render();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String renderTest2() {
|
||||||
|
boolean USER_SHOULD_LOG_IN = true;
|
||||||
|
boolean USER_SHOULD_SIGN_UP = false;
|
||||||
|
return document().render() +
|
||||||
|
html(
|
||||||
|
head(
|
||||||
|
title("Test")
|
||||||
|
),
|
||||||
|
body(
|
||||||
|
header(
|
||||||
|
h1(
|
||||||
|
text("Test Header "),
|
||||||
|
a("with link").withHref("http://example.com"),
|
||||||
|
text(".")
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
footer().withText("Test Footer"),
|
main(
|
||||||
|
h2("Test Form"),
|
||||||
|
div(
|
||||||
|
input().withType("email").withName("email").withPlaceholder("Email"),
|
||||||
|
input().withType("password").withName("password").withPlaceholder("Password"),
|
||||||
|
iff(USER_SHOULD_LOG_IN, button().withType("submit").withText("Login")),
|
||||||
|
iff(USER_SHOULD_SIGN_UP, button().withType("submit").withText("Signup"))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
footer("Test Footer").attr(Attr.CLASS, "footer").condAttr(1 == 1, Attr.ID, "id"),
|
||||||
script().withSrc("/testScript.js")
|
script().withSrc("/testScript.js")
|
||||||
)
|
)
|
||||||
).render();
|
).render();
|
||||||
@@ -38,7 +89,8 @@ public class ComplexRenderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComplexRender() {
|
public void testComplexRender() {
|
||||||
String expectedResult = "<!DOCTYPE html><html><head><title>Test</title></head><body><header><h1>Test Header</h1></header><main><h2>Test Form</h2><div><input type=\"email\" name=\"email\" placeholder=\"Email\"><input type=\"password\" name=\"password\" placeholder=\"Password\"><button type=\"submit\">Login</button></div></main><footer>Test Footer</footer><script src=\"/testScript.js\"></script></body></html>";
|
String expectedResult = "<!DOCTYPE html><html><head><title>Test</title></head><body><header><h1>Test Header <a href=\"http://example.com\">with link</a>.</h1></header><main><h2>Test Form</h2><div><input type=\"email\" name=\"email\" placeholder=\"Email\"><input type=\"password\" name=\"password\" placeholder=\"Password\"><button type=\"submit\">Login</button></div></main><footer class=\"footer\" id=\"id\">Test Footer</footer><script src=\"/testScript.js\"></script></body></html>";
|
||||||
assertEquals(renderTest(), expectedResult);
|
assertThat(renderTest(), is(expectedResult));
|
||||||
|
assertThat(renderTest2(), is(expectedResult));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,32 +2,41 @@ package j2html.tags;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static j2html.TagCreator.*;
|
import static j2html.TagCreator.a;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static j2html.TagCreator.div;
|
||||||
|
import static j2html.TagCreator.form;
|
||||||
|
import static j2html.TagCreator.img;
|
||||||
|
import static j2html.TagCreator.input;
|
||||||
|
import static j2html.TagCreator.link;
|
||||||
|
import static j2html.TagCreator.meta;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class ConvenienceMethodTest {
|
public class ConvenienceMethodTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllConvenienceMethods() throws Exception {
|
public void testAllConvenienceMethods() throws Exception {
|
||||||
assertEquals(input().isAutoComplete().render(), "<input autocomplete>");
|
assertThat(input().isAutoComplete().render(), is("<input autocomplete>"));
|
||||||
assertEquals(input().isAutoFocus().render(), "<input autofocus>");
|
assertThat(input().isAutoFocus().render(), is("<input autofocus>"));
|
||||||
assertEquals(input().isHidden().render(), "<input hidden>");
|
assertThat(input().isHidden().render(), is("<input hidden>"));
|
||||||
assertEquals(input().isRequired().render(), "<input required>");
|
assertThat(input().isRequired().render(), is("<input required>"));
|
||||||
assertEquals(img().withAlt("An image").render(), "<img alt=\"An image\">");
|
assertThat(img().withAlt("An image").render(), is("<img alt=\"An image\">"));
|
||||||
assertEquals(form().withAction("post").render(), "<form action=\"post\"></form>");
|
assertThat(form().withAction("post").render(), is("<form action=\"post\"></form>"));
|
||||||
assertEquals(meta().withCharset("UTF-8").render(), "<meta charset=\"UTF-8\">");
|
assertThat(meta().withCharset("UTF-8").render(), is("<meta charset=\"UTF-8\">"));
|
||||||
assertEquals(div().withClass("test-class").render(), "<div class=\"test-class\"></div>");
|
assertThat(div().withClass("test-class").render(), is("<div class=\"test-class\"></div>"));
|
||||||
assertEquals(meta().withContent("Test Content").render(), "<meta content=\"Test Content\">");
|
assertThat(meta().withContent("Test Content").render(), is("<meta content=\"Test Content\">"));
|
||||||
assertEquals(a().withHref("http://example.com").render(), "<a href=\"http://example.com\"></a>");
|
assertThat(a().withHref("http://example.com").render(), is("<a href=\"http://example.com\"></a>"));
|
||||||
assertEquals(div().withId("test-id").render(), "<div id=\"test-id\"></div>");
|
assertThat(div().withId("test-id").render(), is("<div id=\"test-id\"></div>"));
|
||||||
assertEquals(div().withData("testdata", "test").render(), "<div data-testdata=\"test\"></div>");
|
assertThat(div().withData("testdata", "test").render(), is("<div data-testdata=\"test\"></div>"));
|
||||||
assertEquals(form().withMethod("get").render(), "<form method=\"get\"></form>");
|
assertThat(form().withMethod("get").render(), is("<form method=\"get\"></form>"));
|
||||||
assertEquals(input().withName("test-name").render(), "<input name=\"test-name\">");
|
assertThat(input().withName("test-name").render(), is("<input name=\"test-name\">"));
|
||||||
assertEquals(input().withPlaceholder("test-placeholder").render(), "<input placeholder=\"test-placeholder\">");
|
assertThat(input().withPlaceholder("test-placeholder").render(), is("<input placeholder=\"test-placeholder\">"));
|
||||||
assertEquals(a().withTarget("_blank").render(), "<a target=\"_blank\"></a>");
|
assertThat(a().withTarget("_blank").render(), is("<a target=\"_blank\"></a>"));
|
||||||
assertEquals(input().withType("email").render(), "<input type=\"email\">");
|
assertThat(input().withType("email").render(), is("<input type=\"email\">"));
|
||||||
assertEquals(link().withRel("stylesheet").render(), "<link rel=\"stylesheet\">");
|
assertThat(link().withRel("stylesheet").render(), is("<link rel=\"stylesheet\">"));
|
||||||
assertEquals(img().withSrc("/img/test.png").render(), "<img src=\"/img/test.png\">");
|
assertThat(link().withRole("role").render(), is("<link role=\"role\">"));
|
||||||
assertEquals(input().withValue("test-value").render(), "<input value=\"test-value\">");
|
assertThat(img().withSrc("/img/test.png").render(), is("<img src=\"/img/test.png\">"));
|
||||||
|
assertThat(div().withStyle("background:red;").render(), is("<div style=\"background:red;\"></div>"));
|
||||||
|
assertThat(input().withValue("test-value").render(), is("<input value=\"test-value\">"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
src/test/java/j2html/tags/InlineStaticResourceTest.java
Normal file
45
src/test/java/j2html/tags/InlineStaticResourceTest.java
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package j2html.tags;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static j2html.TagCreator.fileAsEscapedString;
|
||||||
|
import static j2html.TagCreator.fileAsString;
|
||||||
|
import static j2html.TagCreator.scriptWithInlineFile_min;
|
||||||
|
import static j2html.TagCreator.styleWithInlineFile_min;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
public class InlineStaticResourceTest {
|
||||||
|
|
||||||
|
private static final String EOL = System.getProperty("line.separator"); // System independent End Of Line
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAllTags() throws Exception {
|
||||||
|
|
||||||
|
String expectedCss = "<style>body{background:#daa520;margin-bottom:10px;margin-left:10px;margin-right:10px;margin-top:10px}</style>";
|
||||||
|
String expectedJs = "<script>(function(){var test=5;var tast=10;var testTast=test+tast;console.log(testTast);})();</script>";
|
||||||
|
String expectedHtml = "<body>" + EOL + " Any content" + EOL + "</body>" + EOL;
|
||||||
|
String expectedEscapedHtml = "<body>" + EOL + " Any content" + EOL + "</body>" + EOL;
|
||||||
|
String expectedAnyContent = "public class AnyContent{}" + EOL;
|
||||||
|
|
||||||
|
// classpath files
|
||||||
|
assertThat(styleWithInlineFile_min("/test.css").render(), is(expectedCss));
|
||||||
|
assertThat(scriptWithInlineFile_min("/test.js").render(), is(expectedJs));
|
||||||
|
assertThat(fileAsString("/test.html").render(), is(expectedHtml));
|
||||||
|
assertThat(fileAsEscapedString("/test.html").render(), is(expectedEscapedHtml));
|
||||||
|
assertThat(fileAsString("/AnyContent.java").render(), is(expectedAnyContent));
|
||||||
|
|
||||||
|
// files outside classpath
|
||||||
|
assertThat(styleWithInlineFile_min("src/test/files/test.css").render(), is(expectedCss));
|
||||||
|
assertThat(scriptWithInlineFile_min("src/test/files/test.js").render(), is(expectedJs));
|
||||||
|
assertThat(fileAsString("src/test/files/test.html").render(), is(expectedHtml));
|
||||||
|
assertThat(fileAsEscapedString("src/test/files/test.html").render(), is(expectedEscapedHtml));
|
||||||
|
assertThat(fileAsString("src/test/files/AnyContent.java").render(), is(expectedAnyContent));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected=RuntimeException.class)
|
||||||
|
public void testExceptionForBadPath() throws Exception {
|
||||||
|
styleWithInlineFile_min("NOT A FILE");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,178 +1,251 @@
|
|||||||
package j2html.tags;
|
package j2html.tags;
|
||||||
|
|
||||||
import org.junit.Test;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.junit.*;
|
||||||
|
|
||||||
import static j2html.TagCreator.*;
|
import static j2html.TagCreator.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class TagCreatorTest {
|
public class TagCreatorTest {
|
||||||
|
|
||||||
|
private static final String EOL = System.getProperty("line.separator"); // System independent End Of Line
|
||||||
|
|
||||||
|
List<Employee> employees = Arrays.asList(new Employee(1, "Name 1", "Title 1"), new Employee(2, "Name 2", "Title 2"), new Employee(3, "Name 3", "Title 3"));
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIff() throws Exception {
|
||||||
|
String expected = "<div><p>Test</p><a href=\"#\">Test</a></div>";
|
||||||
|
String actual = div(
|
||||||
|
p("Test"),
|
||||||
|
iff(1 == 1, a("Test").withHref("#")),
|
||||||
|
iff(1 == 2, a("Tast").withHref("#"))
|
||||||
|
).render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIffElse() throws Exception {
|
||||||
|
String expected = "<div><p>Tast</p></div>";
|
||||||
|
String actual = div(iffElse(1 == 2, p("Test"), p("Tast"))).render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJoin() throws Exception {
|
||||||
|
String expected = "This is my joined string. It has a <a href=\"#\">link in the middle</a> and <code>code at the end</code>.";
|
||||||
|
String actual = join("This is my joined string. It has a", a("link in the middle").withHref("#"), "and", code("code at the end"), ".").render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore // Having some trouble with RetroLambda setup
|
||||||
|
public void testEach() throws Exception {
|
||||||
|
String j2htmlMap = ul().with(
|
||||||
|
li("Begin list"),
|
||||||
|
each(employees, employee -> li(
|
||||||
|
h2(employee.name),
|
||||||
|
p(employee.title)
|
||||||
|
))
|
||||||
|
).render();
|
||||||
|
String javaMap = ul().with(
|
||||||
|
li("Begin list"),
|
||||||
|
rawHtml(employees.stream().map(employee -> li(
|
||||||
|
h2(employee.name),
|
||||||
|
p(employee.title)
|
||||||
|
)).map(DomContent::render).collect(Collectors.joining()))
|
||||||
|
).render();
|
||||||
|
assertThat(j2htmlMap.equals(javaMap), is(true));
|
||||||
|
assertThat(j2htmlMap, is("<ul><li>Begin list</li><li><h2>Name 1</h2><p>Title 1</p></li><li><h2>Name 2</h2><p>Title 2</p></li><li><h2>Name 3</h2><p>Title 3</p></li></ul>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore // Having some trouble with RetroLambda setup
|
||||||
|
public void testFilter() throws Exception {
|
||||||
|
String j2htmlFilter = ul().with(
|
||||||
|
li("Begin list"),
|
||||||
|
each(filter(employees, e -> e.id % 2 == 1), employee -> li(
|
||||||
|
h2(employee.name),
|
||||||
|
p(employee.title)
|
||||||
|
))
|
||||||
|
).render();
|
||||||
|
String javaFilter = ul().with(
|
||||||
|
li("Begin list"),
|
||||||
|
rawHtml(employees.stream().filter(e -> e.id % 2 == 1).map(employee -> li(
|
||||||
|
h2(employee.name),
|
||||||
|
p(employee.title)
|
||||||
|
)).map(DomContent::render).collect(Collectors.joining()))
|
||||||
|
).render();
|
||||||
|
assertThat(j2htmlFilter.equals(javaFilter), is(true));
|
||||||
|
assertThat(j2htmlFilter, is("<ul><li>Begin list</li><li><h2>Name 1</h2><p>Title 1</p></li><li><h2>Name 3</h2><p>Title 3</p></li></ul>"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllTags() throws Exception {
|
public void testAllTags() throws Exception {
|
||||||
|
|
||||||
//Special Tags
|
//Special Tags
|
||||||
assertEquals(tag("tagname").render(), "<tagname></tagname>");
|
assertThat(tag("tagname").render(), is("<tagname></tagname>"));
|
||||||
assertEquals(emptyTag("tagname").render(), "<tagname>");
|
assertThat(emptyTag("tagname").render(), is("<tagname>"));
|
||||||
assertEquals(text("text").render(), "text");
|
assertThat(text("text").render(), is("text"));
|
||||||
assertEquals(text("<script> and \"</script>\"").render(), "<script> and "</script>"");
|
assertThat(text("<script> and \"</script>\"").render(), is("<script> and "</script>""));
|
||||||
assertEquals(unsafeHtml("<script>").render(), "<script>");
|
assertThat(rawHtml("<script>").render(), is("<script>"));
|
||||||
assertEquals(styleWithInlineFile_min("/test.css").render(), "<style>body{background:#daa520;margin-bottom:10px;margin-left:10px;margin-right:10px;margin-top:10px}</style>");
|
|
||||||
assertEquals(scriptWithInlineFile_min("/test.js").render(), "<script>(function(){console.log(15)})();</script>");
|
|
||||||
assertEquals(fileAsString("/test.html").render(), "<body>\r\n"+" Any content\r\n"+"</body>\r\n");
|
|
||||||
assertEquals(fileAsEscapedString("/test.html").render(), "<body>\r\n"+" Any content\r\n"+"</body>\r\n");
|
|
||||||
assertEquals(fileAsString("/test.java").render(), "public class AnyContent{}\r\n");
|
|
||||||
|
|
||||||
//EmptyTags
|
//EmptyTags
|
||||||
assertEquals(document().render(), "<!DOCTYPE html>");
|
assertThat(document().render(), is("<!DOCTYPE html>"));
|
||||||
assertEquals(area().render(), "<area>");
|
assertThat(area().render(), is("<area>"));
|
||||||
assertEquals(base().render(), "<base>");
|
assertThat(base().render(), is("<base>"));
|
||||||
assertEquals(br().render(), "<br>");
|
assertThat(br().render(), is("<br>"));
|
||||||
assertEquals(col().render(), "<col>");
|
assertThat(col().render(), is("<col>"));
|
||||||
assertEquals(embed().render(), "<embed>");
|
assertThat(embed().render(), is("<embed>"));
|
||||||
assertEquals(hr().render(), "<hr>");
|
assertThat(hr().render(), is("<hr>"));
|
||||||
assertEquals(img().render(), "<img>");
|
assertThat(img().render(), is("<img>"));
|
||||||
assertEquals(input().render(), "<input>");
|
assertThat(input().render(), is("<input>"));
|
||||||
assertEquals(keygen().render(), "<keygen>");
|
assertThat(keygen().render(), is("<keygen>"));
|
||||||
assertEquals(link().render(), "<link>");
|
assertThat(link().render(), is("<link>"));
|
||||||
assertEquals(meta().render(), "<meta>");
|
assertThat(meta().render(), is("<meta>"));
|
||||||
assertEquals(param().render(), "<param>");
|
assertThat(param().render(), is("<param>"));
|
||||||
assertEquals(source().render(), "<source>");
|
assertThat(source().render(), is("<source>"));
|
||||||
assertEquals(track().render(), "<track>");
|
assertThat(track().render(), is("<track>"));
|
||||||
assertEquals(wbr().render(), "<wbr>");
|
assertThat(wbr().render(), is("<wbr>"));
|
||||||
|
|
||||||
//ContainerTags
|
//ContainerTags
|
||||||
assertEquals(a().render(), "<a></a>");
|
assertThat(a().render(), is("<a></a>"));
|
||||||
assertEquals(a("Text").render(), "<a>Text</a>");
|
assertThat(a("Text").render(), is("<a>Text</a>"));
|
||||||
assertEquals(abbr().render(), "<abbr></abbr>");
|
assertThat(abbr().render(), is("<abbr></abbr>"));
|
||||||
assertEquals(address().render(), "<address></address>");
|
assertThat(address().render(), is("<address></address>"));
|
||||||
assertEquals(article().render(), "<article></article>");
|
assertThat(article().render(), is("<article></article>"));
|
||||||
assertEquals(aside().render(), "<aside></aside>");
|
assertThat(aside().render(), is("<aside></aside>"));
|
||||||
assertEquals(audio().render(), "<audio></audio>");
|
assertThat(audio().render(), is("<audio></audio>"));
|
||||||
assertEquals(b().render(), "<b></b>");
|
assertThat(b().render(), is("<b></b>"));
|
||||||
assertEquals(b("Text").render(), "<b>Text</b>");
|
assertThat(b("Text").render(), is("<b>Text</b>"));
|
||||||
assertEquals(bdi().render(), "<bdi></bdi>");
|
assertThat(bdi().render(), is("<bdi></bdi>"));
|
||||||
assertEquals(bdi("Text").render(), "<bdi>Text</bdi>");
|
assertThat(bdi("Text").render(), is("<bdi>Text</bdi>"));
|
||||||
assertEquals(bdo().render(), "<bdo></bdo>");
|
assertThat(bdo().render(), is("<bdo></bdo>"));
|
||||||
assertEquals(bdo("Text").render(), "<bdo>Text</bdo>");
|
assertThat(bdo("Text").render(), is("<bdo>Text</bdo>"));
|
||||||
assertEquals(blockquote().render(), "<blockquote></blockquote>");
|
assertThat(blockquote().render(), is("<blockquote></blockquote>"));
|
||||||
assertEquals(blockquote("Text").render(), "<blockquote>Text</blockquote>");
|
assertThat(blockquote("Text").render(), is("<blockquote>Text</blockquote>"));
|
||||||
assertEquals(body().render(), "<body></body>");
|
assertThat(body().render(), is("<body></body>"));
|
||||||
assertEquals(button().render(), "<button></button>");
|
assertThat(button().render(), is("<button></button>"));
|
||||||
assertEquals(button("Text").render(), "<button>Text</button>");
|
assertThat(button("Text").render(), is("<button>Text</button>"));
|
||||||
assertEquals(canvas().render(), "<canvas></canvas>");
|
assertThat(canvas().render(), is("<canvas></canvas>"));
|
||||||
assertEquals(caption().render(), "<caption></caption>");
|
assertThat(caption().render(), is("<caption></caption>"));
|
||||||
assertEquals(caption("Text").render(), "<caption>Text</caption>");
|
assertThat(caption("Text").render(), is("<caption>Text</caption>"));
|
||||||
assertEquals(cite().render(), "<cite></cite>");
|
assertThat(cite().render(), is("<cite></cite>"));
|
||||||
assertEquals(cite("Text").render(), "<cite>Text</cite>");
|
assertThat(cite("Text").render(), is("<cite>Text</cite>"));
|
||||||
assertEquals(code().render(), "<code></code>");
|
assertThat(code().render(), is("<code></code>"));
|
||||||
assertEquals(colgroup().render(), "<colgroup></colgroup>");
|
assertThat(colgroup().render(), is("<colgroup></colgroup>"));
|
||||||
assertEquals(datalist().render(), "<datalist></datalist>");
|
assertThat(datalist().render(), is("<datalist></datalist>"));
|
||||||
assertEquals(dd().render(), "<dd></dd>");
|
assertThat(dd().render(), is("<dd></dd>"));
|
||||||
assertEquals(dd("Text").render(), "<dd>Text</dd>");
|
assertThat(dd("Text").render(), is("<dd>Text</dd>"));
|
||||||
assertEquals(del().render(), "<del></del>");
|
assertThat(del().render(), is("<del></del>"));
|
||||||
assertEquals(del("Text").render(), "<del>Text</del>");
|
assertThat(del("Text").render(), is("<del>Text</del>"));
|
||||||
assertEquals(details().render(), "<details></details>");
|
assertThat(details().render(), is("<details></details>"));
|
||||||
assertEquals(dfn().render(), "<dfn></dfn>");
|
assertThat(dfn().render(), is("<dfn></dfn>"));
|
||||||
assertEquals(dfn("Text").render(), "<dfn>Text</dfn>");
|
assertThat(dfn("Text").render(), is("<dfn>Text</dfn>"));
|
||||||
assertEquals(dialog().render(), "<dialog></dialog>");
|
assertThat(dialog().render(), is("<dialog></dialog>"));
|
||||||
assertEquals(dialog("Text").render(), "<dialog>Text</dialog>");
|
assertThat(dialog("Text").render(), is("<dialog>Text</dialog>"));
|
||||||
assertEquals(div().render(), "<div></div>");
|
assertThat(div().render(), is("<div></div>"));
|
||||||
assertEquals(dl().render(), "<dl></dl>");
|
assertThat(dl().render(), is("<dl></dl>"));
|
||||||
assertEquals(dt().render(), "<dt></dt>");
|
assertThat(dt().render(), is("<dt></dt>"));
|
||||||
assertEquals(dt("Text").render(), "<dt>Text</dt>");
|
assertThat(dt("Text").render(), is("<dt>Text</dt>"));
|
||||||
assertEquals(em().render(), "<em></em>");
|
assertThat(em().render(), is("<em></em>"));
|
||||||
assertEquals(em("Text").render(), "<em>Text</em>");
|
assertThat(em("Text").render(), is("<em>Text</em>"));
|
||||||
assertEquals(fieldset().render(), "<fieldset></fieldset>");
|
assertThat(fieldset().render(), is("<fieldset></fieldset>"));
|
||||||
assertEquals(figcaption().render(), "<figcaption></figcaption>");
|
assertThat(figcaption().render(), is("<figcaption></figcaption>"));
|
||||||
assertEquals(figcaption("Text").render(), "<figcaption>Text</figcaption>");
|
assertThat(figcaption("Text").render(), is("<figcaption>Text</figcaption>"));
|
||||||
assertEquals(figure().render(), "<figure></figure>");
|
assertThat(figure().render(), is("<figure></figure>"));
|
||||||
assertEquals(footer().render(), "<footer></footer>");
|
assertThat(footer().render(), is("<footer></footer>"));
|
||||||
assertEquals(form().render(), "<form></form>");
|
assertThat(form().render(), is("<form></form>"));
|
||||||
assertEquals(h1().render(), "<h1></h1>");
|
assertThat(h1().render(), is("<h1></h1>"));
|
||||||
assertEquals(h1("Text").render(), "<h1>Text</h1>");
|
assertThat(h1("Text").render(), is("<h1>Text</h1>"));
|
||||||
assertEquals(h2().render(), "<h2></h2>");
|
assertThat(h2().render(), is("<h2></h2>"));
|
||||||
assertEquals(h2("Text").render(), "<h2>Text</h2>");
|
assertThat(h2("Text").render(), is("<h2>Text</h2>"));
|
||||||
assertEquals(h3().render(), "<h3></h3>");
|
assertThat(h3().render(), is("<h3></h3>"));
|
||||||
assertEquals(h3("Text").render(), "<h3>Text</h3>");
|
assertThat(h3("Text").render(), is("<h3>Text</h3>"));
|
||||||
assertEquals(h4().render(), "<h4></h4>");
|
assertThat(h4().render(), is("<h4></h4>"));
|
||||||
assertEquals(h4("Text").render(), "<h4>Text</h4>");
|
assertThat(h4("Text").render(), is("<h4>Text</h4>"));
|
||||||
assertEquals(h5().render(), "<h5></h5>");
|
assertThat(h5().render(), is("<h5></h5>"));
|
||||||
assertEquals(h5("Text").render(), "<h5>Text</h5>");
|
assertThat(h5("Text").render(), is("<h5>Text</h5>"));
|
||||||
assertEquals(h6().render(), "<h6></h6>");
|
assertThat(h6().render(), is("<h6></h6>"));
|
||||||
assertEquals(h6("Text").render(), "<h6>Text</h6>");
|
assertThat(h6("Text").render(), is("<h6>Text</h6>"));
|
||||||
assertEquals(head().render(), "<head></head>");
|
assertThat(head().render(), is("<head></head>"));
|
||||||
assertEquals(header().render(), "<header></header>");
|
assertThat(header().render(), is("<header></header>"));
|
||||||
assertEquals(html().render(), "<html></html>");
|
assertThat(html().render(), is("<html></html>"));
|
||||||
assertEquals(i().render(), "<i></i>");
|
assertThat(i().render(), is("<i></i>"));
|
||||||
assertEquals(i("Text").render(), "<i>Text</i>");
|
assertThat(i("Text").render(), is("<i>Text</i>"));
|
||||||
assertEquals(iframe().render(), "<iframe></iframe>");
|
assertThat(iframe().render(), is("<iframe></iframe>"));
|
||||||
assertEquals(ins().render(), "<ins></ins>");
|
assertThat(ins().render(), is("<ins></ins>"));
|
||||||
assertEquals(ins("Text").render(), "<ins>Text</ins>");
|
assertThat(ins("Text").render(), is("<ins>Text</ins>"));
|
||||||
assertEquals(kbd().render(), "<kbd></kbd>");
|
assertThat(kbd().render(), is("<kbd></kbd>"));
|
||||||
assertEquals(label().render(), "<label></label>");
|
assertThat(label().render(), is("<label></label>"));
|
||||||
assertEquals(label("Text").render(), "<label>Text</label>");
|
assertThat(label("Text").render(), is("<label>Text</label>"));
|
||||||
assertEquals(legend().render(), "<legend></legend>");
|
assertThat(legend().render(), is("<legend></legend>"));
|
||||||
assertEquals(legend("Text").render(), "<legend>Text</legend>");
|
assertThat(legend("Text").render(), is("<legend>Text</legend>"));
|
||||||
assertEquals(li().render(), "<li></li>");
|
assertThat(li().render(), is("<li></li>"));
|
||||||
assertEquals(li("Text").render(), "<li>Text</li>");
|
assertThat(li("Text").render(), is("<li>Text</li>"));
|
||||||
assertEquals(main().render(), "<main></main>");
|
assertThat(main().render(), is("<main></main>"));
|
||||||
assertEquals(map().render(), "<map></map>");
|
assertThat(map().render(), is("<map></map>"));
|
||||||
assertEquals(mark().render(), "<mark></mark>");
|
assertThat(mark().render(), is("<mark></mark>"));
|
||||||
assertEquals(menu().render(), "<menu></menu>");
|
assertThat(menu().render(), is("<menu></menu>"));
|
||||||
assertEquals(menuitem().render(), "<menuitem></menuitem>");
|
assertThat(menuitem().render(), is("<menuitem></menuitem>"));
|
||||||
assertEquals(meter().render(), "<meter></meter>");
|
assertThat(meter().render(), is("<meter></meter>"));
|
||||||
assertEquals(nav().render(), "<nav></nav>");
|
assertThat(nav().render(), is("<nav></nav>"));
|
||||||
assertEquals(noscript().render(), "<noscript></noscript>");
|
assertThat(noscript().render(), is("<noscript></noscript>"));
|
||||||
assertEquals(object().render(), "<object></object>");
|
assertThat(object().render(), is("<object></object>"));
|
||||||
assertEquals(ol().render(), "<ol></ol>");
|
assertThat(ol().render(), is("<ol></ol>"));
|
||||||
assertEquals(optgroup().render(), "<optgroup></optgroup>");
|
assertThat(optgroup().render(), is("<optgroup></optgroup>"));
|
||||||
assertEquals(option().render(), "<option></option>");
|
assertThat(option().render(), is("<option></option>"));
|
||||||
assertEquals(option("Text").render(), "<option>Text</option>");
|
assertThat(option("Text").render(), is("<option>Text</option>"));
|
||||||
assertEquals(output().render(), "<output></output>");
|
assertThat(output().render(), is("<output></output>"));
|
||||||
assertEquals(p().render(), "<p></p>");
|
assertThat(p().render(), is("<p></p>"));
|
||||||
assertEquals(p("Text").render(), "<p>Text</p>");
|
assertThat(p("Text").render(), is("<p>Text</p>"));
|
||||||
assertEquals(pre().render(), "<pre></pre>");
|
assertThat(pre().render(), is("<pre></pre>"));
|
||||||
assertEquals(progress().render(), "<progress></progress>");
|
assertThat(progress().render(), is("<progress></progress>"));
|
||||||
assertEquals(q().render(), "<q></q>");
|
assertThat(q().render(), is("<q></q>"));
|
||||||
assertEquals(q("Text").render(), "<q>Text</q>");
|
assertThat(q("Text").render(), is("<q>Text</q>"));
|
||||||
assertEquals(rp().render(), "<rp></rp>");
|
assertThat(rp().render(), is("<rp></rp>"));
|
||||||
assertEquals(rt().render(), "<rt></rt>");
|
assertThat(rt().render(), is("<rt></rt>"));
|
||||||
assertEquals(ruby().render(), "<ruby></ruby>");
|
assertThat(ruby().render(), is("<ruby></ruby>"));
|
||||||
assertEquals(s().render(), "<s></s>");
|
assertThat(s().render(), is("<s></s>"));
|
||||||
assertEquals(samp().render(), "<samp></samp>");
|
assertThat(s("Text").render(), is("<s>Text</s>"));
|
||||||
assertEquals(script().render(), "<script></script>");
|
assertThat(samp().render(), is("<samp></samp>"));
|
||||||
assertEquals(section().render(), "<section></section>");
|
assertThat(script().render(), is("<script></script>"));
|
||||||
assertEquals(select().render(), "<select></select>");
|
assertThat(section().render(), is("<section></section>"));
|
||||||
assertEquals(small().render(), "<small></small>");
|
assertThat(select().render(), is("<select></select>"));
|
||||||
assertEquals(small("Text").render(), "<small>Text</small>");
|
assertThat(small().render(), is("<small></small>"));
|
||||||
assertEquals(span().render(), "<span></span>");
|
assertThat(small("Text").render(), is("<small>Text</small>"));
|
||||||
assertEquals(span("Text").render(), "<span>Text</span>");
|
assertThat(span().render(), is("<span></span>"));
|
||||||
assertEquals(strong().render(), "<strong></strong>");
|
assertThat(span("Text").render(), is("<span>Text</span>"));
|
||||||
assertEquals(strong("Text").render(), "<strong>Text</strong>");
|
assertThat(strong().render(), is("<strong></strong>"));
|
||||||
assertEquals(style().render(), "<style></style>");
|
assertThat(strong("Text").render(), is("<strong>Text</strong>"));
|
||||||
assertEquals(sub().render(), "<sub></sub>");
|
assertThat(style().render(), is("<style></style>"));
|
||||||
assertEquals(sub("Text").render(), "<sub>Text</sub>");
|
assertThat(sub().render(), is("<sub></sub>"));
|
||||||
assertEquals(summary().render(), "<summary></summary>");
|
assertThat(sub("Text").render(), is("<sub>Text</sub>"));
|
||||||
assertEquals(summary("Text").render(), "<summary>Text</summary>");
|
assertThat(summary().render(), is("<summary></summary>"));
|
||||||
assertEquals(sup().render(), "<sup></sup>");
|
assertThat(summary("Text").render(), is("<summary>Text</summary>"));
|
||||||
assertEquals(sup("Text").render(), "<sup>Text</sup>");
|
assertThat(sup().render(), is("<sup></sup>"));
|
||||||
assertEquals(table().render(), "<table></table>");
|
assertThat(sup("Text").render(), is("<sup>Text</sup>"));
|
||||||
assertEquals(tbody().render(), "<tbody></tbody>");
|
assertThat(table().render(), is("<table></table>"));
|
||||||
assertEquals(td().render(), "<td></td>");
|
assertThat(tbody().render(), is("<tbody></tbody>"));
|
||||||
assertEquals(td("Text").render(), "<td>Text</td>");
|
assertThat(td().render(), is("<td></td>"));
|
||||||
assertEquals(textarea().render(), "<textarea></textarea>");
|
assertThat(td("Text").render(), is("<td>Text</td>"));
|
||||||
assertEquals(tfoot().render(), "<tfoot></tfoot>");
|
assertThat(textarea().render(), is("<textarea></textarea>"));
|
||||||
assertEquals(th().render(), "<th></th>");
|
assertThat(tfoot().render(), is("<tfoot></tfoot>"));
|
||||||
assertEquals(th("Text").render(), "<th>Text</th>");
|
assertThat(th().render(), is("<th></th>"));
|
||||||
assertEquals(thead().render(), "<thead></thead>");
|
assertThat(th("Text").render(), is("<th>Text</th>"));
|
||||||
assertEquals(time().render(), "<time></time>");
|
assertThat(thead().render(), is("<thead></thead>"));
|
||||||
assertEquals(title().render(), "<title></title>");
|
assertThat(time().render(), is("<time></time>"));
|
||||||
assertEquals(tr().render(), "<tr></tr>");
|
assertThat(title().render(), is("<title></title>"));
|
||||||
assertEquals(u().render(), "<u></u>");
|
assertThat(title("Text").render(), is("<title>Text</title>"));
|
||||||
assertEquals(u("Text").render(), "<u>Text</u>");
|
assertThat(tr().render(), is("<tr></tr>"));
|
||||||
assertEquals(ul().render(), "<ul></ul>");
|
assertThat(u().render(), is("<u></u>"));
|
||||||
assertEquals(var().render(), "<var></var>");
|
assertThat(u("Text").render(), is("<u>Text</u>"));
|
||||||
assertEquals(video().render(), "<video></video>");
|
assertThat(ul().render(), is("<ul></ul>"));
|
||||||
|
assertThat(var().render(), is("<var></var>"));
|
||||||
|
assertThat(video().render(), is("<video></video>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,17 @@ package j2html.tags;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static j2html.TagCreator.*;
|
import static j2html.TagCreator.body;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static j2html.TagCreator.div;
|
||||||
|
import static j2html.TagCreator.footer;
|
||||||
|
import static j2html.TagCreator.header;
|
||||||
|
import static j2html.TagCreator.html;
|
||||||
|
import static j2html.TagCreator.iff;
|
||||||
|
import static j2html.TagCreator.main;
|
||||||
|
import static j2html.TagCreator.p;
|
||||||
|
import static j2html.TagCreator.tag;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class TagTest {
|
public class TagTest {
|
||||||
|
|
||||||
@@ -11,28 +20,52 @@ public class TagTest {
|
|||||||
public void testRender() throws Exception {
|
public void testRender() throws Exception {
|
||||||
ContainerTag testTag = new ContainerTag("a");
|
ContainerTag testTag = new ContainerTag("a");
|
||||||
testTag.setAttribute("href", "http://example.com");
|
testTag.setAttribute("href", "http://example.com");
|
||||||
assertEquals(testTag.render(), "<a href=\"http://example.com\"></a>");
|
assertThat(testTag.render(), is("<a href=\"http://example.com\"></a>"));
|
||||||
|
|
||||||
ContainerTag complexTestTag = html().with(body().with(header(), main().with(p("Main stuff...")), footer().condWith(1 == 1, p("Conditional with!"))));
|
ContainerTag complexTestTag = html().with(body().with(header(), main().with(p("Main stuff...")), footer().condWith(1 == 1, p("Conditional with!"))));
|
||||||
String expectedResult = "<html><body><header></header><main><p>Main stuff...</p></main><footer><p>Conditional with!</p></footer></body></html>";
|
String expectedResult = "<html><body><header></header><main><p>Main stuff...</p></main><footer><p>Conditional with!</p></footer></body></html>";
|
||||||
assertEquals(complexTestTag.render(), (expectedResult));
|
assertThat(complexTestTag.render(), is((expectedResult)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOpenTag() throws Exception {
|
public void testOpenTag() throws Exception {
|
||||||
ContainerTag testTag = new ContainerTag("a");
|
ContainerTag testTag = new ContainerTag("a");
|
||||||
assertEquals(testTag.renderOpenTag(), "<a>");
|
assertThat(testTag.renderOpenTag(), is("<a>"));
|
||||||
|
|
||||||
ContainerTag complexTestTag = new ContainerTag("input");
|
ContainerTag complexTestTag = new ContainerTag("input");
|
||||||
complexTestTag.withType("password").withId("password").withName("password").withPlaceholder("Password").isRequired();
|
complexTestTag.withType("password").withId("password").withName("password").withPlaceholder("Password").isRequired();
|
||||||
String expectedResult = "<input type=\"password\" id=\"password\" name=\"password\" placeholder=\"Password\" required>";
|
String expectedResult = "<input type=\"password\" id=\"password\" name=\"password\" placeholder=\"Password\" required>";
|
||||||
assertEquals(complexTestTag.renderOpenTag(), expectedResult);
|
assertThat(complexTestTag.renderOpenTag(), is(expectedResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCloseTag() throws Exception {
|
public void testCloseTag() throws Exception {
|
||||||
ContainerTag testTag = new ContainerTag("a");
|
ContainerTag testTag = new ContainerTag("a");
|
||||||
assertEquals(testTag.renderCloseTag(), "</a>");
|
assertThat(testTag.renderCloseTag(), is("</a>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEquals() throws Exception {
|
||||||
|
Tag tagOne = tag("p").withClass("class").withText("Test");
|
||||||
|
Tag tagTwo = p("Test").withClass("class");
|
||||||
|
assertThat(tagOne.equals(tagTwo), is(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWithClasses() throws Exception {
|
||||||
|
String expected = "<div class=\"c1 c2\"></div>";
|
||||||
|
String actual = div().withClasses("c1", iff(1 == 1, "c2"), iff(1 == 2, "c3")).render();
|
||||||
|
assertThat(actual, is(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmptyAttribute() throws Exception {
|
||||||
|
ContainerTag testTagWithAttrValueNull = new ContainerTag("a").attr("attribute", null);
|
||||||
|
assertThat(testTagWithAttrValueNull.render(), is("<a attribute></a>"));
|
||||||
|
|
||||||
|
ContainerTag testTagAttrWithoutAttr = new ContainerTag("a").attr("attribute");
|
||||||
|
assertThat(testTagAttrWithoutAttr.render(), is("<a attribute></a>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/test/java/j2html/tags/TestClasses.java
Normal file
13
src/test/java/j2html/tags/TestClasses.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package j2html.tags;
|
||||||
|
|
||||||
|
class Employee {
|
||||||
|
final int id;
|
||||||
|
final String name;
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
Employee(int id, String name, String title) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/test/resources/AnyContent.java
Normal file
1
src/test/resources/AnyContent.java
Normal file
@@ -0,0 +1 @@
|
|||||||
|
public class AnyContent{}
|
||||||
Reference in New Issue
Block a user