uklance / tapestry-stitch

Sample components and concepts in Tapestry 5
MIT License
14 stars 7 forks source link

Demo - Convert block to string #14

Closed uklance closed 10 years ago

uklance commented 11 years ago

http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Encoding-a-template-as-a-valid-JSON-String-td5723504.html

uklance commented 10 years ago

The component should have two options. Either set a property or invoke a method with the HTML string.

TML

<t:stitch.tostring value="myValue">tml goes here</t:stitch.tostring>
<t:stitch.tostring handler="myToStringHandler">tml goes here</t:stitch.tostring>

Java

// will contain the html after the tostring component has rendered
@Property
private String myValue;

public ToStringHandler getMyToStringHandler() {
   return new ToStringHandler() {
      // will be invoked during the rendering of the tostring component
      public void onToString(String html) {
         // do stuff with html
      }
   };
}
uklance commented 10 years ago

Capture component + demo added http://tapestry-stitch.uklance.cloudbees.net/capturedemo