Passing collection value from Template to Iron Router for csv download

I am trying to send my Iron router the name attribute of the current collection item I am in.

The name of the collection I am in is on the URL so I use

`Router.current().params.name`

to get the name. Because each name in the Nodes collection is unique but along with the name there are many sensor data elements I need to grab depending on time.

What I am trying to do is Download this data into an xlsx or csv file of just the current name documents of the collection. Because there are many different names the name of the current page is very important. I have seen a way to get a csv file with stackOverflow Example. However this is only useful if I am already subscribing to the entire collection and not looking for anything unique. The pages I go to only subscribe to 20 items of a unique name to keep page load times low, but there are thousands data points for each unique name.

Is there a way to send send the current name to Iron router for a new page load usign that stackoverflow example?

I have also seen the blob example but what I really need is the ability to get the entire collection and query my specific name based on the current page I am on. Blob example

SOLVED. Although I did want to put up how I did this.

Client HTML

   `{{#with download}}
        <a href="{{pathFor 'download.name'}}" target="Router.current()">Download {{name}} Data</a>
    {{/with}}`

Client JS
remember only 20 items are available on this page. so find will only return the page’s unique named items because I only subscribe to those. if needed I can post the publish and subscribe as well.

`Template.DOWNLOAD.helpers({
    download: function(){
        return Nodes.findOne();
    }
  })`

Router code in lib file

`Router.route('/download/:name',{
  // The name so it goes to the route and not the name of that link which is     the page they are 
  // already on.
  name: 'download.name',
  // These functions are on the server so they have access to the full      collection.
  where: 'server',
  action: function(){
  var filename = 'data_file.csv';
  var fileData ="";

  var headers ={
  'Content-type': 'text/csv',
  'Content-Disposition': "attachment; filename =" +filename
     };
        var records = Nodes.find({name: this.params.name},{sort: {createdAt: -1}});

        fileData = this.params.name+"\r\n";
        fileData += "Created At"+","+"Direction"+","+"Speed"+","+"Humidity"+","+"Temperature"+","+"Dew Point"+","+"Pressure"+","+"Latitude"+","+"Longitude"+"\r\n";
        records.forEach(function(rec){
        fileData += rec.createdAt+","+rec.direction+","+rec.speed+","+rec.humidity+","+rec.temp+","+rec.dew+","+rec.pressure+","+rec.latitude+","+rec.longitude+"\r\n";
     });
     this.response.writeHead(200,headers);
     return this.response.end(fileData);
   }
});`