How to use the ejs.fileLoader function in ejs

To help you get started, we’ve selected a few ejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github census-instrumentation / opencensus-node / packages / opencensus-exporter-zpages / src / zpages-frontend / page-handlers / rpcz.page-handler.ts View on Github external
emitHtml(json: boolean): string {
    /** template HTML */
    const rpczFile = ejs.fileLoader(`${templatesDir}/rpcz.ejs`).toString();
    /** CSS styles file */
    const stylesFile = ejs
      .fileLoader(`${templatesDir}/styles.min.css`)
      .toString();
    /** EJS render options */
    const options = { delimiter: '?' };

    const rpcViews = this.statsParams.registeredViews.filter(
      view => view.name.indexOf('http') < 0
    );
    const rpczData: RpczData = { measuresSent: {}, measuresReceived: {} };

    for (const view of rpcViews) {
      const recordedData = this.statsParams.recordedData[view.name];

      let clientMethodIndex = -1;
github census-instrumentation / opencensus-node / packages / opencensus-exporter-zpages / src / zpages-frontend / page-handlers / statsz.page-handler.ts View on Github external
private loaderFile(fileName: string): string {
    const fileDir = path.join(templatesDir, fileName);
    return ejs.fileLoader(fileDir, 'utf8');
  }
}
github census-instrumentation / opencensus-node / packages / opencensus-exporter-zpages / src / zpages-frontend / page-handlers / traceconfigz.page-handler.ts View on Github external
emitHtml(params: Partial, json: boolean): string {
    if (params) {
      this.saveChanges(params);
    }

    if (!this.defaultConfig) {
      this.defaultConfig = {
        samplingRate: TraceConfigzPageHandler.extractSamplingProbability(),
      };
    }

    /** template HTML */
    const traceConfigzFile = ejs
      .fileLoader(`${templatesDir}/traceconfigz.ejs`)
      .toString();
    /** EJS render options */
    const options = { delimiter: '?' };
    /** Current sampling rate  */
    const samplingProbability = TraceConfigzPageHandler.extractSamplingProbability();

    /** Rendering the HTML table summary */
    const renderParams: TraceConfigzData = {
      defaultConfig: this.defaultConfig,
      samplingProbability,
    };
    if (json) {
      return JSON.stringify(renderParams, null, 2);
    } else {
      return ejs.render(traceConfigzFile, renderParams, options);
github census-instrumentation / opencensus-node / packages / opencensus-exporter-zpages / src / zpages-frontend / page-handlers / tracez.page-handler.ts View on Github external
emitHtml(params: Partial, json: boolean): string {
    const tracezFile = ejs.fileLoader(`${templatesDir}/tracez.ejs`).toString();
    const stylesFile = ejs
      .fileLoader(`${templatesDir}/styles.min.css`)
      .toString();
    const summaryFile = ejs
      .fileLoader(`${templatesDir}/summary.ejs`)
      .toString();
    const spanCellFile = ejs
      .fileLoader(`${templatesDir}/span-cell.ejs`)
      .toString();
    const spansFile = ejs.fileLoader(`${templatesDir}/spans.ejs`).toString();
    /** EJS render options */
    const options = { delimiter: '?' };
    /** Latency array */
    const latencyBucketBoundaries = LatencyBucketBoundaries.values;
    /** Latency names list */
    const latencyBucketNames = [];