Skip to content

Commit fa1c915

Browse files
committed
add loadContent to View class
1 parent 1d02188 commit fa1c915

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/main/java/act/view/View.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
import act.plugin.AppServicePlugin;
88
import act.plugin.Plugin;
99
import act.util.ActContext;
10+
import org.osgl.util.C;
11+
import org.osgl.util.IO;
1012
import org.osgl.util.S;
1113

1214
import java.io.File;
15+
import java.util.List;
1316

1417
/**
1518
* The base class that different View solution should extends
@@ -61,6 +64,22 @@ protected final String templateHome() {
6164
return templateHome;
6265
}
6366

67+
/**
68+
* Load template content.
69+
*
70+
* This method is used by error reporting feature when app running in dev mode
71+
* @param template the template path
72+
* @return the template content in lines
73+
*/
74+
protected List<String> loadContent(String template) {
75+
File file = new File(templateRootDir(), template);
76+
if (file.exists() && file.canRead()) {
77+
return IO.readLines(file);
78+
}
79+
return C.list();
80+
}
81+
82+
6483
protected final File templateRootDir() {
6584
App app = Act.app();
6685
return new File(app.layout().resource(app.base()), templateHome());

0 commit comments

Comments
 (0)