Hi!
I'm submitting a feature request to get angular universal working with spring boot
I've been playing with Spring Boot and Nashorn to render javascript views which works great.
Now I would like to get NG2 working with Nashorn.
I've could help out with implementing it but I need some guidance.
To render .ejs files with nashorn you create a spring bean as follows
@Bean
public ScriptTemplateConfigurer reactConfigurer() {
ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
configurer.setEngineName("nashorn");
configurer.setScripts(
"templates/polyfill.js",
"templates/ejs.min.js",
"templates/render.js"
);
configurer.setRenderFunction("render");
configurer.setSharedEngine(false);
return configurer;
}
// polyfill.js
var window = this;
var global = this;
var console = {};
console.debug = print;
console.warn = print;
console.log = print;
console.error = print;
// render.js
// Create a real JSON object from the model Map
function toJsonObject(model) {
var o = {};
for (var k in model) {
// Convert Iterable like List to real JSON array
if (model[k] instanceof Java.type("java.lang.Iterable")) {
o[k] = Java.from(model[k]);
}
else {
o[k] = model[k];
}
}
return o;
}
function render(template, model) {
return ejs.render(template, toJsonObject(model));
}
Have any of you done any tests with nashorn?
Could you point me in the right direction to get started?
Perhaps the discussion in #280 would be a better place to reach out for some guidance.
Hi @leon! How are you? Could you have a good solution/prototype for a ng+springboot project?
Thanks in advance.
Nico
Closed in favour of https://github.com/angular/universal/issues/1000
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Hi @leon! How are you? Could you have a good solution/prototype for a ng+springboot project?
Thanks in advance.
Nico