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:

  1. you not explicitly set data argument instance of chart template (the last 2 lines in java code throw exception).
  2. the chart template not rendered independently. if needed render chart template without html template, you'd need define new template standalonechart(data, chart) allow render chart template in context defines data.

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -