@midwayjs/view
Version:
Midway Component for render view
45 lines • 1.4 kB
TypeScript
import { IViewEngine } from './interface';
export declare class ViewManager extends Map {
protected app: any;
protected viewConfig: any;
protected config: any;
protected extMap: Map<any, any>;
protected fileMap: Map<any, any>;
protected localsMap: {};
protected init(): void;
/**
* This method can register view engine.
*
* You can define a view engine class contains two method, `render` and `renderString`
*
* ```js
* class View {
* render() {}
* renderString() {}
* }
* ```
* @param {String} name - the name of view engine
* @param {Object} viewEngine - the class of view engine
*/
use(name: string, viewEngine: new (...args: any[]) => IViewEngine): void;
/**
* Resolve the path based on the given name,
* if the name is `user.html` and root is `view` (by default),
* it will return `view/user.html`
* @param {String} name - the given path name, it's relative to config.root
* @return {String} filename - the full path
*/
resolve(name: string): Promise<string>;
/**
* add a global data for all views
* @param key
* @param localValue
*/
addLocals(key: any, localValue: any): void;
/**
* get global locals data
*/
getLocals(): {};
findEngine(ext: string): string;
}
//# sourceMappingURL=viewManager.d.ts.map