Pass template parameter to {{#if}} block

I call my upload template with the parameter type of "logo":

{{> upload type="logo"}}

My upload template looks like this:

<template name="upload">
    <table class="table">
        {{#if uploads type="{{type}}" }}
            <tr>
                <td>{{type}}</td>
                <td><a href="{{url download=true}}" class="download-icon"><i class="fa fa-cloud-download fa-2x"></i></a></td>
                <td class="delete" data-name="{{type}}"><i class="fa fa-trash fa-2x"></i></td>
            </tr>
        {{/if}}
    </table>
</template>

The {{type}} in the two td work, but the one in the {{#if}} block doesn’t. I’ve tried it with and without quotes. How can I pass the type template parameter to the {{#if}} block?

you are not passing it to #if block, but uploads helper
in that case uploads helper should expect argument, but not assignment
what you are trying to accomplish ?

And you are already in {{}} block, so normal type=name would be correct assignment, but it does not make sense in this exact scenario.

That’s true. My template helper is currently:

uploads: function(evt) {
    return Uploads.find({
        type: evt.hash.type,
        sponsor: Meteor.user().profile.sponsor
    });
}

If I hard code the value in like this {{#if uploads type="logo"}}, it works great.

I’m trying to abstract the file upload functionality. Ideally, I’d like to use it this way:

{{> upload type="logo"}}
{{> upload type="speakerPicture"}}
{{> upload type="presentation"}}

So why not {{#if uploads type }} ?

uploads: function(type) {
    return Uploads.find({
        type: type,
        sponsor: Meteor.user().profile.sponsor
    });
}

I updated it, not uploads name, but uploads type probably for your usecase, I dont know where that “name” came from :smiley:

That got it fixed. I knew I was thinking too hard. :wink: Thanks!

That’s got to be a world record response time too, by the way.

But my little search engine is not responding very fast, probably it is time to setup mongodb ttl to remove offline livestreams instead of just switching them off in property :smiley:

> db.streams.find({online: true},{_id: 1}).count()
21206
> db.streams.count()
1434514
>