Add a pure DOM passage
With the movement to JS functions for creating the passage content, the next step would be to get rid of the whole SC Wikifier step and just include our DOM objects directly in the DOM tree. All of this obviously only possible for passages that are mostly DOM already.
This introduces a Passage class that inherits from SCs Passage and renders the output of a function.
Advantages:
- SC Wikifier does not get invoked
- No need for nearly empty
.tw
files
Disadvantages:
- Number of
.tw
files won't be equal to number of passages as it is currently. - For now depends on some project specific settings, for example
Config.passages.descriptions
being set, but this could be improved.
Problems:
- Certain functions may produce different results depending on when they are called during loading (ex.:
Story.lookup()
) until all passages are added. Easy solution is to just call them as the last step during loading, eg. fromzz1-last
. - We can't do this (as easily) for the sidebar as it is rendered slightly differently, so really we are only getting from 2 Wikifiers to 1 Wikifier per passage load.
Question:
- What would be the better place to put the DomPassage creation? A dedicated file or near where the rendering function is defined?
- Is this actually useful?
Converted Options
as an example.
Merge request reports
Activity
Neat. I'd thought about doing something similar...this solution is a LOT simpler than I expected it would need to be, which is awesome.
I don't think ".tw file count equal to passage count" is important at all (certainly not enough to qualify as a disadvantage...and I think it might actually be an advantage). Nor do I consider requiring
Config.passages.descriptions
and similar to be a disadvantage for us.Load order could be solved with a bit of reorganization. We could split passages out into their own folder, or if we used a dedicated file to register the passages we could just do it before the main source loaded (maybe even outside the eval).
Sidebar is a separate problem; I don't think it's really relevant for this MR.
Edited by svornostadded 2 commits
added src/005-passages/ directory for the passage creation code. Having the passages be created early does mean though that we always have to create a new wrapper function, even if not needed(Intro passages basically).
Converted all Options passages to pure DOM
On thing that popped up is that we can't include those passages, not that it matters since they are all DOM anyways.
Edited by Arkerthanmentioned in commit 1512a5dd
mentioned in issue #2623 (closed)