Hi all, it seems with the #extend tag in Leaf the context is automatically passed from the renderer. However if you have a more complicated (or nested) context, it doesn't seem to know how to separate keys. For example if you have the following:
struct ParentContext: Encodable {
let title: String
let infoButton: Button
}
ButtonContext.swift
struct Button: Encodable {
let title: String
}
And you render this with
let button = ButtonContext(title: "Button title")
let context = ParentContext(title: "Parent title", infoButton: button)
request.view.render("parent", context)
Both the parent.leaf and the button.leaf will try and use the 'title' property on ParentContext. Resulting both #(title) to display "Parent title". Is there a way to specify sub contexts for #extend? For example something like:
Leaf's design means that the context is global across all templates and sub-templates. This is a deliberate decision to make it much simpler to implement and to avoid confusing people.
The easiest way around is just to change the name to something like infoButtonTitle