Context
Context in HMPL is a concept that describes the environment of a certain block.
request
Section titled “request”This context describes the environment within a single specific request.
Property | Type | Description |
---|---|---|
event | Event | undefined | This property provides access to the event object described in the after attribute |
clearInterval | HMPLClearInterval | undefined | Required to stop the interval described in the corresponding attribute |
const templateFn = hmpl.compile( `<div> <button data-action="increment" id="btn">Click!</button> <div>Clicks: {{#request src="/api/clicks" interval=1000 after="click:#btn"}}{{/request}}</div> </div>`);const elementObj = templateFn({ get: (prop, value, context, request) => { console.log(context); }});
{ request: { event: Event, clearInterval: () => void } }