I have set value in model like this
model.val = 'myval'
render(view: 'index', model: model)
& in gsp is there some way by which I could directly get the value of model something like this?
<script id="myTemplate" type="text/x-handlebars-template">
{{val}}
</script>
if I try with {{${val}}}
then I get the value but is that right way to do it? I mean expression inside handlebars
const body_data = {
nodes: [
{data: {id: 'j', name: 'Jerry'}},
{data: {id: 'e', name: 'Elaine'}},
{data: {id: 'k', name: 'Kramer'}},
{data: {id: 'g', name: 'George'}},
{data: {id: 'd', name: 'Daniel'}},
{data: {id: 'r', name: 'Rea'}}
],
edges: [
{data: {source: 'j', target: 'e'}},
{data: {source: 'j', target: 'k'}},
{data: {source: 'j', target: 'g'}},
{data: {source: 'e', target: 'k'}},
{data: {source: 'k', target: 'g'}},
{data: {source: 'd', target: 'g'}},
{data: {source: 'g', target: 'r'}},
]
};
res.render('home', {
nombre: 'Leonardo',
body_data,
});
const hbs = require('hbs');
hbs.registerHelper('muestraData', ( data = {} ) => {
return JSON.stringify(data);
});
<script>
const data = {{{ muestraData body_data }}};
console.log(data);
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.