Forum OpenACS Development: Templating in OpenACS and TCL

Collapse
Posted by Neophytos Demetriou on
there must be a way to represent a page as a tree of UI granules/portlets [components] that depend on a collection of data sets and their decoration and placement (layout). -- Neophytos Demetriou (November 16, 2005)

I had proposed that back in 2005. At the time, a prominent member of the community wrote a lengthy article to explain about the culture of complexity in OpenACS. I valued other people's opinion too much at the time. So, I did not do anything about it.

In 2013, I wrote a templating system along those lines that I presented in EuroTCL 2013 in Munich. You can find the presentation here. The mistake I made at the time was that I was compiling the page to C for performance. I was with no money and no job at the time. So, I did not get to improve it further.

This time, it is happening folks. Just wanted to let you in on the news.

PS1. I was between this and starting a new framework in react but I never followed the crowds even though it would have been much easier for me as I have been developing my own projects in react for at least 5 years now.

PS2. In my humble opinion, we forgot how to think big in the TCL community. That is perhaps part of the reason there is no longer support for it in basic tools (e.g. IDEs) and other popular projects (e.g. AWS Lambda Functions).

PS3. You need to be a little crazy to pursue this kind of projects that perhaps some will claim nobody wants to use but as some of you know already, I fit the bill nicely here.

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).

Collapse
Posted by Neophytos Demetriou on
Just a heads up that I got my first templating page (proof of concept) hydrating on the client-side with react. There is still a lot of work to be done here as I now have three compilers (c, tcl, and react) that are out of sync with each other and the code needs polishing but it works!