KNowledgeOnWebScale / walder

Walder offers an easy way to set up a website or Web API on top of decentralized knowledge graphs.
MIT License
63 stars 9 forks source link

Template files are now only loaded once, then cached. #92

Closed renevds closed 3 years ago

renevds commented 3 years ago

This solves #87 The template files are loaded once after their existence is validated inside the html-validator. One instance of the template-loader is created in walder.js and passes through. The template-loader takes an HTMLInfo object and saves its front-matter, it also does this recursively for layouts used by the given template. When the front-matter is needed later, getTemplateFromCache is to be used.

Because both html-converter and the new template-loader require the HTMLInfoof the layout if one exists. I have given HTMLInfo a function that takes a layout file path and returns a new HTMLInfo object for that layout.

Two tests where added.

In the future it might be good to edit HTMLInfo to contain a pointer towards the HTMLInfo of its layout and other front-matter, this way front-matter and HTMLInfo can be one object.