An interesting new feature has been added with version 0.4.1 of Raconteur. From the changelog:
0.4.1 (May 13th, 2015)
Each situation with content is now output as its own <section>
element. Each situation with content clears the #current-situation
id from previous situations and gives its content section that id.
Writers, instead of inserting before the .options
or at the end of the content spool, now insert at the end of the #current-situation
. This behaviour has ramifications if you’re doing strange things with Raconteur situations, but if you’re using most of the features as intended this change should be transparent.
The gain from this feature is significant: Situations can now be styled individually, or in groups by giving the situation a classes
property.
The major potential pitfalls are: first, the “changeover” happens at the content-printing step of RaconteurSituation#enter
, so if you define a “before” function in your situation and refer to the #current-situation
that will still be the previous situation. Second, if you are using Undum’s low-level API to write to the end of the content spool (With system#write
for instance) and mixing that with Raconteur writers, you might have odd behaviour where text is popping up where you don’t expect it. The fix is to make sure you always writeInto
the #current-situation
section, OR that you use system#write
throughout that situation instead. It might be useful to create a new, empty #current-situation
at the bottom of the content spool by entering a situation with a function that returns empty string as its content.
I’ve merged this feature into the stable branch. If you try it out and have problems or questions, let me know.