// AppDataWithKey works similarly to AppData, but uses the provided key instead. // Also, if the data is not found in the *app.App passed in as the first argument, // its children apps are also searched. This allows reusable apps to retrieve their // additional data in contexts where the reusable app pointer is not available. // (e.g. in template plugins which are called from the parent app). See gnd.la/apps/users // for an example of this usage. func AppDataWithKey(a *app.App, key interface{}) interface{} { ra, _ := a.Get(key).(*App) if ra != nil { return ra.Data() } if key != reusableAppKey { for _, ia := range a.Included() { if data := AppDataWithKey(ia, key); data != nil { return data } } } return nil }