lattice-core v0.12 Release Notes

  • ๐Ÿ”„ Changes

    A significant change for better handling the DOM; an object can now be completely contained and return via to_html. Prior to this change, WebObject did not enclose itself with an html element. It now does so, with options to control the generated tag (i.e., modify classes, add a DOM id). For example, the card_game sample's card_game.slang previously did something like this to show the chat_room:

    div.chat_room data-item=chat_room.dom_id data-subscribe=""
      == chat_room.content
    

    ๐Ÿ‘€ In retrospect, this seems like a glaring oversight. Now, card_game.slang only needs this:

    == chat_room.to_html
    

    With this change, it becomes a lot easier to have a container, and now there's no need for StaticBuffer(strings) and DynamicBuffer(WebObjects). The new ObjectList handles both, and they can be intermixed. In fact, this makes it easier to do add any class that can have advanced rendering capabilities without the extra overhead of WebObject. Consider a Counter class that just renders a...counter:

    class Counter
      property value = 0
      def to_html( dom_id )
        "<span data-item='#{dom_id}' class='counter'>#{@value}</span>"
      end
    end
    

    The index is already added to the passed dom_id from render_item. Subclassing ObjectList would be simple, and still allow other types:

    class CounterList < ObjectList
      alias ListType = Counter | WebObject | String
    end
    

    What makes this especially crazy, is it's now possible to have nested containers, each rendering its own stuff.

    Javascript

    app.js had some changes required by this new methodology. Events and subscriptions are now added automatically when content changes through any WebObject.

    However, this is still a major work in progress.