Page and component script render functions and the context object
Key Takeaway
A render function receives a context object and must return markup as a string. In context.content, each attribute sits under its attribute ID, already resolved into an API object where needed. A category attribute is a dw.catalog.Category, so you call getID() on it to get its ID.
In Page Designer, each page type and component type has a script file with a render function that turns its content into HTML. B2C Commerce calls that function and passes it a context object. The context object holds the page or component being rendered, its attribute values, and other inputs the script needs. To build page and component types that marketers can use, you need to know what each context object contains and what the render function must return.
Files for a page type or component type
Each page type and component type needs two files with the same name in the same folder: a JSON meta definition file and a script file with a .js extension. For example, promopage.json and promopage.js form one pair. File names can use only alphanumeric or underscore characters.