So about this new (keyword)[affected material] format that is being used for hooks in Harlowe Twine 2.0...
I just realized it was similar to other things I have seen on the Web lately, including the Reddit spoiler format, which is similar, i.e. (spoiler)[here is my spoiler]. (I had to change the brackets or else it wouldn't show up here, but you get the idea)
Is this syntax part of some standard JavaScript templating system, like Mustache? Is there a name for this syntax?
Comments
Early in development, it was intended that Harlowe use Markdown exclusively, but I personally disagree with a number of MD's decisions, such as using "1.", "2.", etc. for numbered lists, underlining the previous line to create a <h1>, and other stuff. MD was designed with one core principle: it should look good in raw format as well as in rendered format, so that you can use it in multiple services such as email or blog comments, and it can gracefully "fall back" to the raw format when a service doesn't support it. This doesn't make sense for Harlowe because there's only one service (Harlowe's game engine) and the raw code will (usually) never be shown to the player. So, many of MD's tradeoffs (ambiguity in syntax, mostly) were traded back by me as I developed Harlowe's syntax.
Anyway, the tagged hook syntax |name>[contents] was inspired specifically by MD's citation syntax, and was intended to allow you to place a named hook inside, say, a large paragraph, then use a (click: ?name) macro afterward where there's more room (hence the name "hook", in the sense that you can "attach" functionality on a distant span of text).
The syntax of affixing a macro to an untagged hook was designed to resemble Twine 1's usual <<if>><<endif>> enclosures, but conveniently reusing the same syntactic structure as a tagged hook - replacing the tag with a command to immediately perform on it. What I liked about it during the design process was that attaching flow control conditions using (if:) and (unless:) uses the same structures as attaching special styling using (text-style:) and (font:) - in Twine 1, these are essentially completely different.
I do still wonder about where the limits are as far as nesting hooks inside other hooks. The other day I tried to put some <c1| type hooks inside some hook that was in another hook, and I wasn't sure if I was running up against some limitation based on how this stuff gets interpreted. (One of these days I want to look at the Harlowe code and get a better handle on how it goes about interpreting the code.)