Template code Chunk output
{#example_1}
<div style="width:{$width|qcalc(+20)}px; border: 1px solid red">
 <div style="width:{$width}px; margin:0 auto; border: 1px solid green">
   Inside div is {$width} pixels wide.
   Outside div needs to be {$width|qcalc(+20)} pixels wide
   (inside width plus 10 pixels of margin to each side).
   
   Yes, this is a contrived example, but real-life applications do exist.
 </div>
</div>
{#}
Theme theme = new Theme("examples");

// Fetch template from this file: themes/examples/calc.chtml
// Inside that file there is a template "snippet" named #example_1
Chunk html = theme.makeChunk("calc#example_1");

html.set("width", "200");

html.render( out );
<div style="width:220px; border: 1px solid red">
 <div style="width:200px; margin:0 auto; border: 1px solid green">
   Inside div is 200 pixels wide.
   Outside div needs to be 220 pixels wide
   (inside width plus 10 pixels of margin to each side).
   
   Yes, this is a contrived example, but real-life applications do exist.
 </div>
</div>

Inside div is 200 pixels wide. Outside div needs to be 220 pixels wide (inside width plus 10 pixels of margin to each side). Yes, this is a contrived example, but real-life applications do exist.