My front-end application uses Pug to generate the index
page.
Being a Vue.js application, it can be served from Java (production purpose) or Node (develop purpose)
DEVELOP
Variables in index.pug
are injected by running this command:
pug -P -s -O ./variables.js -o ./ index.pug
variables.js
is something like:
variables = {
value: 'something'
}
Variables inside index.pug
can be readed like:
if variables.value == 'something'
//show some tags ecc...
All is working fine.
PRODUCTION
To render index.pug server side I use jade4j
In index controller I do something like:
@RequestMapping(value = "/index.htm")
public ModelAndView indexView(...) {
... other code here...
ModelAndView mav = new ModelAndView("index");
mav.addObject("value", "something");
return mav;
}
but value
can be readed in a script.
tag by this syntax '#{value}'
like in this example:
script.
console.log('#{value}') // prints "something"
How can I read value
in the DEVELOP scenario above?