Polish script based view tests
Issue: SPR-12266
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
var window = {};
|
||||
@@ -1,5 +0,0 @@
|
||||
// TODO Manage compiled template cache
|
||||
function render(template, model) {
|
||||
var compiledTemplate = Handlebars.compile(template);
|
||||
return compiledTemplate(model);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<html><head><title>{{title}}</title></head><body><p>{{body}}</p></body></html>
|
||||
@@ -0,0 +1,3 @@
|
||||
function render(template, model) {
|
||||
return template.replace("{{title}}", model.title).replace("{{body}}", model.body);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
var global = this;
|
||||
var console = {};
|
||||
console.debug = print;
|
||||
console.warn = print;
|
||||
console.log = print;
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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)));
|
||||
}
|
||||
});
|
||||
@@ -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>
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user