Running Thymol.js with a different DOM Engine

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Running Thymol.js with a different DOM Engine

tburny
As discussed per https://github.com/thymol/thymol.js/issues/19 I'm opening a topic on this.

Basically Thymol.js seems to be built to run in a browser. However it could be much more useful to use it as a general templating engine for Node.js. For instance we are using Thymol for the node edition of patternlab.

That is, the DOM engine Thymol requires is the one of a web browser like Firefox's. This engine uses the DOM level 4.
However there is no default DOM engine in Node.js, but there are projects to emulate the browser DOM (having objects like window and document).
Currentlly the only engine Thymol works with is "jsdom", which is terribly slow. In the issue I mentioned that a major speedup could be archieved.
To explain: There are different Document Object Model standards leveled from 1 to 4 (?), where a higher level extends all previous levels (e.g. adding window and document objects).

So I'd like to suggest to steps:
1. I'll do a pull request so that Thymol can be used with a Browser or Domino (which is much faster). This requires only minimal changes to the existing codebase and can be implemented in a very compatible way.
2. Thymol uses jQuery for a few simple queries. However jQuery requires a compatible DOM level. I am wondering if we could get rid of jQuery completely in the core engine code and also switch to a lower DOM level. DOM Level 2 supports namespaces (https://www.w3.org/TR/1999/WD-DOM-Level-2-19990719/namespaces.html) and that's all we need in an XML based template engine. However currently Thymol.js does only work with DOM level 4.
Reply | Threaded
Open this post in threaded view
|

Re: Running Thymol.js with a different DOM Engine

jjbenson
Administrator
Hi tburny,

  You're quite right, Thymol was originally a purely browser based system. It was designed to emulate Thymeleaf as closely as possible, executing on the client side.

  The node.js related Thymol projects are derived from the original client-side code: thymol-node is an abstraction that processes a DOM tree and thymol-node-server is an express based wrapper for it.

  I would dearly love to be rid of jQuery, as you say it's used for simple queries and filters but also as a browser independent wrapper for XHR, some events and JSON parse operations. I'm sure all of these uses could easily be replaced by better alternatives.

  So in short I say, "bring on the pull request", let's see how it tests.

  Kind Regards,

    Jim