core/frontend/services/helpers/handlebars.js
// Register an async handlebars helper for a given handlebars instance
Register an async handlebars helper for a given handlebars instance
Register an async handlebars helper for a given handlebars instance
function asyncHelperWrapper(hbsInstance, name, fn) {
    hbsInstance.registerAsyncHelper(name, async function returnAsync(context, options, cb) {
        if (!cb) {
            cb = options;
            options = undefined;
        }
        try {
            const response = await fn.call(this, context, options);
            cb(response);
        } catch (error) {
            const wrappedErr = errors.utils.isGhostError(error) ? error : new errors.IncorrectUsageError({
                err: error,
                context: 'registerAsyncThemeHelper: ' + name,
                errorDetails: {
                    originalError: error
                }
            });
            const response = process.env.NODE_ENV === 'development' ? wrappedErr : '';
            logging.error(wrappedErr);
            cb(new hbsInstance.SafeString(response));
        }
    });
}
function asyncHelperWrapper ( hbsInstance , name , fn ) { hbsInstance . registerAsyncHelper ( name , async function returnAsync ( context , options , cb ) { if ( ! cb ) { cb = options ; options = undefined ; } try { const response = await fn . call ( this , context , options ) ; cb ( response ) ; } catch ( error ) { const wrappedErr = errors . utils . isGhostError ( error ) ? error : new errors . IncorrectUsageError ( { err : error , context : 'registerAsyncThemeHelper: ' + name , errorDetails : { originalError : error } } ) ; const response = process . env . NODE_ENV === 'development' ? wrappedErr : '' ; logging . error ( wrappedErr ) ; cb ( new hbsInstance . SafeString ( response ) ) ; } } ) ; }
Register an async handlebars helper for a given handlebars instance
Register an async handlebars helper for a given handlebars instance
// Handle the case where we only get context and cb