java - Template application default parameter -
i'll try make problem seem simple, hoping solution be.
let's state have 2 templates following :
html(data,value,charts) ::= << <!doctype html> <html> [...] var $data$ = $value$; $charts$ [...] </html> >> chart(chartname,data,categoryname,graphs) ::= << var $chartname$; $chartname$.dataprovider = $data$; [...] >>
in java, have like:
st mypage = group.getinstanceof("html"); st chart1 = group.getinstanceof("chart"); st chart2 = group.getinstanceof("chart"); mypage.add("data", xxx ); chart1.add("data", xxx ); chart2.add("data", xxx );
but, "data" same (code duplication!), apply "chart" template on data in "html" template :
html(data,value,charts) ::= << [...] var $data$ = $value$; $charts(data)$ [...] >>
which not possible, because "chart" template more parameter "data".
my question : how call "chart" template, using "html"."data" "chart"."data" keeping usual way set parameter @ runtime .add(string, object) ..?
thank time !
one option remove data
parameter chart
template. doing allow cause reference data
within chart
attribute in calling context (e.g. html
template). however, mean following well:
- you not explicitly set
data
argument instance ofchart
template (the last 2 lines in java code throw exception). - the
chart
template not rendered independently. if needed renderchart
template withouthtml
template, you'd need define new templatestandalonechart(data, chart)
allow renderchart
template in context definesdata
.
Comments
Post a Comment