當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Response.render方法代碼示例

本文整理匯總了TypeScript中express.Response.render方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Response.render方法的具體用法?TypeScript Response.render怎麽用?TypeScript Response.render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在express.Response的用法示例。


在下文中一共展示了Response.render方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: create

    export function create (req: Request, res: Response) {
        let generated = false;
        let key = randomString(50);
        let secret = null;

        if (!req.body.secret) {
            console.log('generate');
            generated = true;
            secret = randomString(20);
        } else {
            console.log('create');
            secret = req.body.secret;
        }

        r.store(key, secret);

        let secret_url = req.headers['host'] + '/get/' + key;

        if (generated) {
            console.log('generated');
            res.render('generate', { generated: secret, secret_url: secret_url});
        } else {
            console.log('created');
            res.render('created', { url: secret_url });
        }
    }
開發者ID:j3lte,項目名稱:secretsexchangejs,代碼行數:26,代碼來源:store.ts

示例2:

        }), req.body["password"], (err: any, account: any) => {
            if (err) {
                return res.render("auth", { title: "Auth Error " + err });
            }

            res.render("auth", { title: "Signup Success" });
        });
開發者ID:zhfuzzy,項目名稱:FullstackTypescript,代碼行數:7,代碼來源:auth.ts

示例3: list

	list(req: Request, res: Response) {
		if (process.env.NODE_ENV === 'testing') {
			res.render('ng-unit-tests');
		} else {
			res.render('index');
		}
	}
開發者ID:eduncan26,項目名稱:ng2-boilerplate,代碼行數:7,代碼來源:core.controller.ts

示例4:

export const about = (req: Request, res: Response) => {
  if (res.locals.device === DEVICE.MOBILE) {
    res.render('home/about-mobile', {
      title: '關於聽說 - 世界很大,風住過這裏',
      bodyClassName: 'body-home-about'
    })
  } else {
    res.render('home/about', {
      pageIndex: 3,
      title: '關於聽說 - 世界很大,風住過這裏',
    })
  }
}
開發者ID:linkFly6,項目名稱:Said,代碼行數:13,代碼來源:home.ts

示例5: internalError

/**
 * Render status `500` page.
 */
function internalError(res: Response, err?: Error): void {
   if (is.value(err)) {
      log.error(err);
   }
   res.statusCode = HttpStatus.InternalError;
   res.render(Page.InternalError, { title: 'Oops', config });
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:10,代碼來源:view.ts

示例6:

app.use(function(err: HttpError, req: Request, res: Response) {
    res.status(err.status || 500);
    res.render("error", {
        error: {},
        message: err.message,
    });
});
開發者ID:phroph,項目名稱:node-factorio-launcher,代碼行數:7,代碼來源:app.ts

示例7: tags

function tags(req: Request, res: Response) {
   let slug = tagParam(req);
   const list = blog.tags;
   const keys = Array.from(list.keys());
   const tags: { [key: string]: { [key: string]: string } } = {};

   if (is.empty(slug)) {
      // select a random tag
      slug = keys[Math.floor(Math.random() * keys.length + 1)];
   }

   // group tags by first letter (character)
   for (const c of alphabet) {
      tags[c] = {};
   }
   for (const [key, value] of list.entries()) {
      // key is sometimes a number
      const c = (key.toString()).substr(0, 1).toLowerCase();
      if (alphabet.indexOf(c) >= 0) {
         // ignore tags that don't start with a letter of the alphabet
         tags[c][key] = value;
      }
   }

   res.render(Page.PhotoTag, {
      tags,
      selected: slug,
      alphabet,
      title: keys.length + ' Photo Tags',
      config
   });
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:32,代碼來源:photo.ts

示例8: index

  public async index(req: Request, res: Response, next: any) {
    try {
      const seasons = await this.sql.getAllSeasonsForMenu();
      const selectedSeason = await this.sql.getSelectedSeason(req.query.season);

      if (selectedSeason === undefined) {
        // season does not exist
        res.status(404).send("Season not found");
        return;
      }

      const startDate = selectedSeason.getStartDate();
      if (startDate > new Date() && req.query.skip !== "1") {
        res.redirect(307, "/new");
      }

      const teams = selectedSeason.teams.map((t) => ({ id: t.slug, name: t.name }));
      res.render("home/index_noteam", {
        title: selectedSeason.pageTitle,
        teams,
        slug: selectedSeason.slug,
        seasons,
      });
    } catch (e) {
      next(e);
    }
  }
開發者ID:snickroger,項目名稱:FantasyMovieLeague,代碼行數:27,代碼來源:homeController.ts

示例9:

  app.use(function (req: IRequest, res: Response, next: NextFunction): void {
    res.status(err.status || 500);
  res.render('error', {
    error: {},
    message: err.message
  });
});
開發者ID:dadakoko,項目名稱:play-server,代碼行數:7,代碼來源:app.ts

示例10: get

  public async get(req: Request, res: Response, next: any) {
    try {
      const movieId = parseInt(req.params.id, 10);
      const teamId = parseInt(req.query.team, 10);
      const team = await this.sql.getTeam(teamId);
      if (team === undefined) {
        res.status(404).send("Team not found");
        return;
      }

      const movie = await this.sql.getMovie(movieId, team);
      if (movie === undefined) {
        res.status(404).send("Movie not found");
        return;
      }

      const movieEarnings = MovieEarnings.getMovieEarningsDisplay(movie, team.players);
      const totalShares = movieEarnings.totalShares();
      const totalEarned = movieEarnings.totalEarnedDisp();
      const chart = MovieEarnings.getMovieEarningsChartData(movie);

      res.render("movie/get", {
        chart,
        movie,
        movieEarnings,
        team,
        title: `${movie.name} | Earnings`,
        totalEarned,
        totalShares,
      });
    } catch (e) {
      next(e);
    }
  }
開發者ID:snickroger,項目名稱:FantasyMovieLeague,代碼行數:34,代碼來源:movieController.ts

示例11: async

    get: async (req: Request, res: Response) => {
        const users = await getClient().many(query);
        
        const groupedUsers = _.groupBy(users, u => u.role);

        res.render("users", {users: groupedUsers});
    }
開發者ID:paavohuhtala,項目名稱:lodgist,代碼行數:7,代碼來源:Users.ts

示例12:

 let handler = (err: Error, req: Request, res: Response, next: Function, includeStackTrace: boolean) => {
   res.status(res.statusCode || 500);
   res.render('error', {
     message: err.message,
     error:   includeStackTrace ? err : {}
   });
 };
開發者ID:j3lte,項目名稱:secretsexchangejs,代碼行數:7,代碼來源:errorHandler.ts

示例13: blogMap

/**
 * @see https://www.mapbox.com/mapbox-gl-js/example/cluster/
 */
function blogMap(_req: Request, res: Response) {
   res.render(Page.Mapbox, {
      layout: Layout.None,
      title: config.site.title + ' Map',
      config
   });
}
開發者ID:Trail-Image,項目名稱:blog,代碼行數:10,代碼來源:map.ts

示例14:

 app.use(function(err: any, req: Request, res: Response, next: Function): void {
     res.status(err.status || 500);
     res.render("error", {
         message: err.message,
         error: err,
     });
 });
開發者ID:gvprime,項目名稱:microsoft-teams-sample-complete-node,代碼行數:7,代碼來源:app.ts

示例15:

app.use(function(err: any, req: Request, res: Response, next: Function) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});
開發者ID:giespaepen,項目名稱:ExpressControllers,代碼行數:7,代碼來源:app.ts


注:本文中的express.Response.render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。