Skip to content

Commit 3b06328

Browse files
committed
Spring integration not clear jknack#59
* fix double prefix in view resolver
1 parent c1edb69 commit 3b06328

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

handlebars-springmvc/src/main/java/com/github/jknack/handlebars/springmvc/HandlebarsViewResolver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ protected AbstractUrlBasedView buildView(final String viewName)
8484
protected AbstractUrlBasedView configure(final HandlebarsView view)
8585
throws IOException {
8686
String url = view.getUrl();
87-
// Remove suffix
88-
url = url.substring(0, url.length() - getSuffix().length());
87+
// Remove prefix & suffix.
88+
url = url.substring(getPrefix().length(), url.length()
89+
- getSuffix().length());
8990
// Compile the template.
9091
view.setTemplate(handlebars.compile(URI.create(url)));
9192
return view;
@@ -109,7 +110,7 @@ public void afterPropertiesSet() throws Exception {
109110
new Handlebars(new SpringTemplateLoader(getApplicationContext()));
110111
}
111112
TemplateLoader templateLoader = handlebars.getTemplateLoader();
112-
// Override preffix and sufffix.
113+
// Override prefix and suffix.
113114
templateLoader.setPrefix(getPrefix());
114115
templateLoader.setSuffix(getSuffix());
115116
}

handlebars-springmvc/src/test/java/com/github/jknack/handlebars/springmvc/HandlebarsViewResolverTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void configureNoDash() throws Exception {
4747
expect(handlebars.compile(URI.create("home"))).andReturn(template);
4848

4949
HandlebarsView view = createMock(HandlebarsView.class);
50-
expect(view.getUrl()).andReturn("home.hbs");
50+
expect(view.getUrl()).andReturn("/home.hbs");
5151
view.setTemplate(template);
5252
expectLastCall();
5353

@@ -65,7 +65,7 @@ public void configureWithDash() throws Exception {
6565
Template template = createMock(Template.class);
6666

6767
Handlebars handlebars = createMock(Handlebars.class);
68-
expect(handlebars.compile(URI.create("/home"))).andReturn(template);
68+
expect(handlebars.compile(URI.create("home"))).andReturn(template);
6969

7070
HandlebarsView view = createMock(HandlebarsView.class);
7171
expect(view.getUrl()).andReturn("/home.hbs");

0 commit comments

Comments
 (0)