Forum OpenACS Development: Re: Templating in OpenACS and TCL

Collapse
Posted by Neophytos Demetriou on
Here are some initial goals for this project:

1. It should work along side acs-templating.
2. It should provide tools to work with a TCL-ish version of JSX.
3. It should integrate with react on the client side.

Very ambitious goals but I will have to give it a try before I give up on it. In case it is not clear, my plan is to be able to (a) write JS together with TCL, (b) templating/TCL will handle the server-side rendering, and (c) React hydration should still work on the client-side.

It is not a goal of this project to support everything that you can do with Node.js on the server-side. Just basic functionality as a proof of concept and then whatever makes sense.

For example, here is a React component that I use as a litmus test:

function Counter() {
  // Set the initial count state to zero, 0
  const [count, setCount] = useState(0);

  // Create handleIncrement event handler
  const handleIncrement = () => {
    setCount(prevCount => prevCount + 1);
  };

  //Create handleDecrement event handler
  const handleDecrement = () => {
    setCount(prevCount => prevCount - 1);
  };
  return (
    <div>
      <div>
        <button onClick={handleDecrement}>-</button>
        <h5>Count is {count}</h5>
        <button onClick={handleIncrement}>+</button>
      </div>
      <button onClick={() => setCount(0)}>Reset</button>
    </div>
  );
}

If that is successful I will try to assemble all pages in a package into a Single Page Application with routing on the client side.

Bonus points if I can get it to serve partial components i.e. the client asks for parts of the page to be rendered (see React Server Components for the idea behind this).