I want the href tag dynamically and the value will be populated, and I have an ejs template

Example code snippet:

index.ejs

<p><a href="<%=link%>" class="btn btn-primary" role="button">Download</a></p>  

app.js

var express = require('express'); var router = express.Router(); 

router.get('/', function(req, res, next) {
    res.render('index', {link:'http://download1588.mediafireuserdownload.com/**c5cq****rb2a/***.jpg'});
}); 

how to get this link as the value of the href tag so that I can download from this link.

+4
source share
2 answers

Instead of giving a single quote, we should use a double quote. how

index.ejs

<p><a href="<%= link %>" class="btn btn-primary" role="button">Download</a></p>

app.js

res.render('index.ejs', { link: " your link " });
0
source

Here's how you could do it with ejs:

index.ejs

<p><a href="<%= link %>" class="btn btn-primary" role="button">Download</a></p>

app.js

res.render('index.ejs', { link: "<your link here>" });

Hope this helps!

+5
source

Source: https://habr.com/ru/post/1671522/


All Articles