java - Passing JSON Object to Rythm template -


i have rythm templates registry , need develop code render selected client template (e.g. client call code http , provide template name , parameters). due call performed http - on end have client-provided params json (i have not classes represent user input), maybe parsed map of maps of maps.... , turn out it's not handy use such structure in template: can use map::get(key) method , 1 level nesting:

next template error due param.get("person") supposed object , have not get(key) method:

@args map<string, object> param hello @param.get("person").get("firstname").capfirst()! 

i remember template engines support map-as-object syntax, e.g. pass map of maps of ... of objects template , access in template pojo (or accessing json object's field in js), exapmle:

@args map param hello @param.person.firstname.capfirst()! 

is possible rythm?

or maybe there convinient way solve such problem?

try dynamic evaluation putting @ @ end of expression:

@args com.alibaba.fastjson.jsonobject param hello @param.person.firstname.capfirst()@! 

see http://fiddle.rythmengine.org/#/editor/ed3855c628144af287571cdf9857bcaa


Comments