Polish script based view tests

Issue: SPR-12266
This commit is contained in:
Sebastien Deleuze
2015-05-05 11:38:47 +02:00
parent e306098155
commit 7919364db6
21 changed files with 18 additions and 286 deletions

View File

@@ -34,8 +34,8 @@
<mvc:groovy-configurer resource-loader-path="/test" cache-templates="false" auto-indent="true" />
<mvc:script-template-configurer engine-name="nashorn" render-object="Mustache" render-function="render" charset="ISO-8859-1" resource-loader-path="classpath:">
<mvc:script location="/META-INF/resources/webjars/mustachejs/0.8.2/mustache.js" />
<mvc:script-template-configurer engine-name="nashorn" render-function="render" charset="ISO-8859-1" resource-loader-path="classpath:">
<mvc:script location="org/springframework/web/servlet/view/script/nashorn/render.js" />
</mvc:script-template-configurer>
</beans>

View File

@@ -1,5 +0,0 @@
// TODO Manage compiled template cache
function render(template, model) {
var compiledTemplate = Handlebars.compile(template);
return compiledTemplate(model);
}

View File

@@ -1 +0,0 @@
<html><head><title>{{title}}</title></head><body><p>{{body}}</p></body></html>

View File

@@ -0,0 +1,3 @@
function render(template, model) {
return template.replace("{{title}}", model.title).replace("{{body}}", model.body);
}

View File

@@ -1,5 +0,0 @@
var global = this;
var console = {};
console.debug = print;
console.warn = print;
console.log = print;

View File

@@ -1,13 +0,0 @@
function render(template, model) {
// Create a real Javascript Object from the model Map
var data = {};
for(var k in model) data[k]=model[k];
var element = React.createElement(eval(template), data);
// Should use React.renderToString in production
return React.renderToStaticMarkup(element);
}
function renderJsx(template, model) {
var jsTemplate = JSXTransformer.transform(template).code;
return render(jsTemplate, model);
}

View File

@@ -1,5 +0,0 @@
React.createClass({
render: function() {
return React.createElement("html", null, React.createElement("head", null, React.createElement("title", null, this.props.title)), React.createElement("body", null, React.createElement("p", null, this.props.body)));
}
});

View File

@@ -1,5 +0,0 @@
React.createClass({
render: function() {
return <html><head><title>{this.props.title}</title></head><body><p>{this.props.body}</p></body></html>
}
});