aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2019-04-07 12:44:36 +0200
committerMarvin Borner2019-04-07 12:44:36 +0200
commitd60bf9b546bca3e479668de801e8821e19abbb9e (patch)
tree8a1f19bd697e7178bc4f816f5ec911d45a3d5a34
parent51c6451b36e8f3845ba278d42e7c4a9941556986 (diff)
Added layouts for rocker views
-rw-r--r--src/main/resources/generated-views/files.java68
-rw-r--r--src/main/resources/generated-views/fileview.java61
-rw-r--r--src/main/resources/views/files.rocker.html2
-rw-r--r--src/main/resources/views/fileview.rocker.html18
-rw-r--r--src/main/resources/views/layout.rocker.html15
5 files changed, 96 insertions, 68 deletions
diff --git a/src/main/resources/generated-views/files.java b/src/main/resources/generated-views/files.java
index ee232d2..443d91a 100644
--- a/src/main/resources/generated-views/files.java
+++ b/src/main/resources/generated-views/files.java
@@ -31,7 +31,7 @@ public class files extends com.fizzed.rocker.runtime.DefaultRockerModel {
}
static public long getModifiedAt() {
- return 1554383637381L;
+ return 1554633755940L;
}
static public String[] getArgumentNames() {
@@ -91,37 +91,43 @@ public class files extends com.fizzed.rocker.runtime.DefaultRockerModel {
@Override
protected void __doRender() throws IOException, RenderingException {
- // ForBlockBegin @ [3:1]
+ // ValueClosureBegin @ [3:1]
__internal.aboutToExecutePosInTemplate(3, 1);
- try {
- final com.fizzed.rocker.runtime.IterableForIterator<String> __forIterator0 = new com.fizzed.rocker.runtime.IterableForIterator<String>(files);
- while (__forIterator0.hasNext()) {
- final String file = __forIterator0.next();
- try {
- // PlainText @ [3:29]
- __internal.aboutToExecutePosInTemplate(3, 29);
- __internal.writeValue(PLAIN_TEXT_0_0);
- // ValueExpression @ [4:10]
- __internal.aboutToExecutePosInTemplate(4, 10);
- __internal.renderValue(file, false);
- // PlainText @ [4:15]
- __internal.aboutToExecutePosInTemplate(4, 15);
- __internal.writeValue(PLAIN_TEXT_1_0);
- // ValueExpression @ [4:17]
- __internal.aboutToExecutePosInTemplate(4, 17);
- __internal.renderValue(file, false);
- // PlainText @ [4:22]
- __internal.aboutToExecutePosInTemplate(4, 22);
- __internal.writeValue(PLAIN_TEXT_2_0);
- // ForBlockEnd @ [3:1]
- __internal.aboutToExecutePosInTemplate(3, 1);
- } catch (com.fizzed.rocker.runtime.ContinueException e) {
- // support for continuing for loops
- }
- } // for end @ [3:1]
- } catch (com.fizzed.rocker.runtime.BreakException e) {
- // support for breaking for loops
- }
+ __internal.renderValue(layout.template(files.size() + " Files").__body(() -> {
+ // ForBlockBegin @ [4:1]
+ __internal.aboutToExecutePosInTemplate(4, 1);
+ try {
+ final com.fizzed.rocker.runtime.IterableForIterator<String> __forIterator0 = new com.fizzed.rocker.runtime.IterableForIterator<String>(files);
+ while (__forIterator0.hasNext()) {
+ final String file = __forIterator0.next();
+ try {
+ // PlainText @ [4:29]
+ __internal.aboutToExecutePosInTemplate(4, 29);
+ __internal.writeValue(PLAIN_TEXT_0_0);
+ // ValueExpression @ [5:10]
+ __internal.aboutToExecutePosInTemplate(5, 10);
+ __internal.renderValue(file, false);
+ // PlainText @ [5:15]
+ __internal.aboutToExecutePosInTemplate(5, 15);
+ __internal.writeValue(PLAIN_TEXT_1_0);
+ // ValueExpression @ [5:17]
+ __internal.aboutToExecutePosInTemplate(5, 17);
+ __internal.renderValue(file, false);
+ // PlainText @ [5:22]
+ __internal.aboutToExecutePosInTemplate(5, 22);
+ __internal.writeValue(PLAIN_TEXT_2_0);
+ // ForBlockEnd @ [4:1]
+ __internal.aboutToExecutePosInTemplate(4, 1);
+ } catch (com.fizzed.rocker.runtime.ContinueException e) {
+ // support for continuing for loops
+ }
+ } // for end @ [4:1]
+ } catch (com.fizzed.rocker.runtime.BreakException e) {
+ // support for breaking for loops
+ }
+ // ValueClosureEnd @ [3:1]
+ __internal.aboutToExecutePosInTemplate(3, 1);
+ }), false); // value closure end @ [3:1]
}
}
diff --git a/src/main/resources/generated-views/fileview.java b/src/main/resources/generated-views/fileview.java
index 14b1a70..7400da2 100644
--- a/src/main/resources/generated-views/fileview.java
+++ b/src/main/resources/generated-views/fileview.java
@@ -11,6 +11,9 @@ import java.io.IOException;
@SuppressWarnings("unused")
public class fileview extends com.fizzed.rocker.runtime.DefaultRockerModel {
+ // argument @ [1:2]
+ private String filename;
+
static public com.fizzed.rocker.ContentType getContentType() {
return com.fizzed.rocker.ContentType.HTML;
}
@@ -24,20 +27,20 @@ public class fileview extends com.fizzed.rocker.runtime.DefaultRockerModel {
}
static public String getHeaderHash() {
- return "868254209";
+ return "-79956506";
}
static public long getModifiedAt() {
- return 1554408818000L;
- }
-
- static public String[] getArgumentNames() {
- return new String[]{"content"};
+ return 1554633681210L;
}
// argument @ [1:2]
private String content;
+ static public String[] getArgumentNames() {
+ return new String[]{"content", "filename"};
+ }
+
public fileview content(String content) {
this.content = content;
return this;
@@ -47,9 +50,19 @@ public class fileview extends com.fizzed.rocker.runtime.DefaultRockerModel {
return this.content;
}
- static public fileview template(String content) {
+ static public fileview template(String content, String filename) {
return new fileview()
- .content(content);
+ .content(content)
+ .filename(filename);
+ }
+
+ public fileview filename(String filename) {
+ this.filename = filename;
+ return this;
+ }
+
+ public String filename() {
+ return this.filename;
}
@Override
@@ -60,19 +73,18 @@ public class fileview extends com.fizzed.rocker.runtime.DefaultRockerModel {
static public class Template extends com.fizzed.rocker.runtime.DefaultRockerTemplate {
- // <!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta content=\"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\"\n name=\"viewport\">\n <meta content=\"ie=edge\" http-equiv=\"X-UA-Compatible\">\n <title>Fileview</title>\n</head>\n<body>\n
+ // \n
static private final byte[] PLAIN_TEXT_0_0;
- // \n</body>\n</html>\n
- static private final byte[] PLAIN_TEXT_1_0;
static {
PlainTextUnloadedClassLoader loader = PlainTextUnloadedClassLoader.tryLoad(fileview.class.getClassLoader(), fileview.class.getName() + "$PlainText", "UTF-8");
PLAIN_TEXT_0_0 = loader.tryGet("PLAIN_TEXT_0_0");
- PLAIN_TEXT_1_0 = loader.tryGet("PLAIN_TEXT_1_0");
}
// argument @ [1:2]
protected final String content;
+ // argument @ [1:2]
+ protected final String filename;
public Template(fileview model) {
super(model);
@@ -81,26 +93,29 @@ public class fileview extends com.fizzed.rocker.runtime.DefaultRockerModel {
__internal.setTemplateName(getTemplateName());
__internal.setTemplatePackageName(getTemplatePackageName());
this.content = model.content();
+ this.filename = model.filename();
}
@Override
protected void __doRender() throws IOException, RenderingException {
- // PlainText @ [1:23]
- __internal.aboutToExecutePosInTemplate(1, 23);
- __internal.writeValue(PLAIN_TEXT_0_0);
- // ValueExpression @ [13:5]
- __internal.aboutToExecutePosInTemplate(13, 5);
- __internal.renderValue(content, false);
- // PlainText @ [13:13]
- __internal.aboutToExecutePosInTemplate(13, 13);
- __internal.writeValue(PLAIN_TEXT_1_0);
+ // ValueClosureBegin @ [3:1]
+ __internal.aboutToExecutePosInTemplate(3, 1);
+ __internal.renderValue(layout.template("File " + filename).__body(() -> {
+ // ValueExpression @ [4:1]
+ __internal.aboutToExecutePosInTemplate(4, 1);
+ __internal.renderValue(content, false);
+ // PlainText @ [4:9]
+ __internal.aboutToExecutePosInTemplate(4, 9);
+ __internal.writeValue(PLAIN_TEXT_0_0);
+ // ValueClosureEnd @ [3:1]
+ __internal.aboutToExecutePosInTemplate(3, 1);
+ }), false); // value closure end @ [3:1]
}
}
private static class PlainText {
- static private final String PLAIN_TEXT_0_0 = "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta content=\"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\"\n name=\"viewport\">\n <meta content=\"ie=edge\" http-equiv=\"X-UA-Compatible\">\n <title>Fileview</title>\n</head>\n<body>\n ";
- static private final String PLAIN_TEXT_1_0 = "\n</body>\n</html>\n";
+ static private final String PLAIN_TEXT_0_0 = "\n";
}
diff --git a/src/main/resources/views/files.rocker.html b/src/main/resources/views/files.rocker.html
index 45a009f..097918a 100644
--- a/src/main/resources/views/files.rocker.html
+++ b/src/main/resources/views/files.rocker.html
@@ -1,5 +1,7 @@
@import java.util.ArrayList
@args (ArrayList files)
+@layout.template(files.size() + " Files") -> {
@for (String file : files) {
<a href="@file">@file</a><br>
}
+}
diff --git a/src/main/resources/views/fileview.rocker.html b/src/main/resources/views/fileview.rocker.html
index 250f34f..03a7418 100644
--- a/src/main/resources/views/fileview.rocker.html
+++ b/src/main/resources/views/fileview.rocker.html
@@ -1,15 +1,5 @@
-@args (String content)
+@args (String content, String filename)
-<!doctype html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
- name="viewport">
- <meta content="ie=edge" http-equiv="X-UA-Compatible">
- <title>Fileview</title>
-</head>
-<body>
- @content
-</body>
-</html>
+@layout.template("File " + filename) -> {
+@content
+}
diff --git a/src/main/resources/views/layout.rocker.html b/src/main/resources/views/layout.rocker.html
new file mode 100644
index 0000000..583c723
--- /dev/null
+++ b/src/main/resources/views/layout.rocker.html
@@ -0,0 +1,15 @@
+@args (String title, RockerBody content)
+
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
+ name="viewport">
+ <meta content="ie=edge" http-equiv="X-UA-Compatible">
+ <title>@title</title>
+</head>
+<body>
+@content
+</body>
+</html>