Skip to content

Pre-Render Hook #623

@jonwinton

Description

@jonwinton

Idea: preRender hook in model.js

Purpose: Sets context of request by providing a context specific object which components can attach data to. This would then be passed into the render function to basically allow context specific data to be shared across components.

Good use case: we want specific ad injection logic defined on the layout level to be respected by an article. A component in the layout contains the specification of the logic, attaches it to ctx, and then the article can read it. Also ,maybe some dedupe logic in feeds?

Example:

module.exports.beforeRender = (uri, data) => {
    return {foo: 'bar'};
}

module.exports.render = (uri, data, locals, ctx) => {
    data.foo = ctx.foo;
    return data;
}

Not settled, but just putting something down.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions