Getting the url parameters in an ejs template

前端 未结 3 1172
孤独总比滥情好
孤独总比滥情好 2021-02-05 19:15

I am trying to create an ejs conditional based on a URL parameter, for example, if the test parameter exists at localhost:3000/page?test, then show a div, else dont show it.

3条回答
  •  庸人自扰
    2021-02-05 19:49

    just the send the stuff in the form of query which can be easily retrieved

    app.get('/category', function(req, res) {
      var string = stuff
      res.redirect('/?valid=' + string);
    }); 
    

    In the ejs template you can directly use parameter name

    <% var k = valid %>
    

提交回复
热议问题