Remove the circular dependency between Core/Language and Core/Template
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 5 Feb 2021 11:19:57 +0000 (12:19 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 5 Feb 2021 11:19:57 +0000 (12:19 +0100)
commit4cb0e576949b0223279e32bc26533cf9607fab23
tree7d1e166a048060a1ef2c2224c9cfb249babac22f
parentf1b262fcfee8d1574a0f0483f4e0b7fe551b76cf
Remove the circular dependency between Core/Language and Core/Template

The old work-around for this issue was no longer working well since the
migration to TypeScript. This commit untangles both modules, by each splitting
them into a low level and a high level interface.

The largest change is that language items are compiled when add()ing them to
the language store instead of when get()ting the contents.

This might slightly reduce the initialization performance on pages with a large
number of unused language items and it also might increase memory usage, due to
needing to store functions instead of strings.

It however improves the readability of the code and of course it also fixes
this breakage introduced by TypeScript. If it turns out that the change
actually *is* an issue then the logic can be optimized, e.g. by skipping the
template compiler if no `{` can be found within the phrase that is being
add()ed to the language store.
ts/WoltLabSuite/Core/Language.ts
ts/WoltLabSuite/Core/Language/Store.ts [new file with mode: 0644]
ts/WoltLabSuite/Core/Template.ts
ts/WoltLabSuite/Core/Template/Compiler.ts [new file with mode: 0644]
wcfsetup/install/files/js/WoltLabSuite/Core/Language.js
wcfsetup/install/files/js/WoltLabSuite/Core/Language/Store.js [new file with mode: 0644]
wcfsetup/install/files/js/WoltLabSuite/Core/Template.js
wcfsetup/install/files/js/WoltLabSuite/Core/Template/Compiler.js [new file with mode: 0644]