Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8961823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:58:53+00:00 2026-06-15T15:58:53+00:00

I have an array like this: var arr = [element1,element2]; and I would like

  • 0

I have an array like this:

var arr = ["element1","element2"];

and I would like to get the elements of it in a handlebars file.

I googled with no result the only solution what i found is this:

{{#each files}}
<a href="/"{{path}}"">{{title}}</a>
{{/each}}

But this is not good for me because I would like to achive that all of my files in a directory could be downloadable.

The code what I tried on the server side:

app.get('/download',function(req,res){
var items;
fs.readdir('./download',function(err,files){
        items = files;
});

res.render('download',{
    files:items
});
});

And I don’t know how to iterate on the client side to make all of the elements in the array downloadable.

On the clien side I have an unordered list which will contain the links. The problem is, that I have no idea how to achive that.

The code on the clien side:

<div id="container">
            <div class="highlight">
                <img src="img/highlight.png"></img>
                <p>A Click to download</p>
            </div>
            <ul>
                <li class="RoundedAll"><a href="/">Back</a></li>
            </ul>
            <br />
            <ul>
                <!-- What should I put here? -->
            </ul>
        </div>

Thanks for answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:58:54+00:00Added an answer on June 15, 2026 at 3:58 pm

    First of all, lets assume that your files:items is a handlebar’d array looking kinda like this.

    { files:['filenameOne.ext', 'filenameTwo.ext', 'filenameThree.exe'] };
    

    Now when you’ve written this on the response and you want to loop over the array in handlebars.js this is how your HTML should look like, using your code.

    <div id="container">
        <div class="highlight">
            <img src="img/highlight.png"></img>
            <p>A Click to download</p>
        </div>
        <ul>
            <li class="RoundedAll"><a href="/">Back</a></li>
        </ul>
        <br />
        <ul>
            {{#each files}}
            <li>{{this}}</li>
            {{/each}}
        </ul>
    </div>
    

    The <li>{{this}}</li> will contain the filename’s that is contained within your list.
    To then access that you would have to make a <a> that links to a controller, app.get('/getActualFile', function(){ //serve the file here }); and then write the fetched file on the response.

    Hope this points you in the right the direction and that the use of an iterator in handlebars is a bit more obvious.

    I myself does not prefer handlebars but that is since i’m not used to it completely.
    I myself like this template-language for Node.js better, http://paularmstrong.github.com/swig/

    It features a bit more “clear” syntax but is probably worse than handlebars considering the diffrent ways you can customize Handlebars.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array like this var Arr = [ 'h78em', 'w145px', 'w13px' ] I
I have an array like this var records:Object = {}; var arr:Array = [
If I have an array like this: var arr = ['one','two','three']; I can access
I have an array that after being sorted appears like this: var arr =
I have an array like this var array = [{ order: 3, sub -
I have an array like this: var arr1 = [a, b, c, d]; How
Say, I have an array that looks like this: var playlist = [ {artist:Herbie
I have a map array with objects stuffed with variables looking like this: var
I have javascript code some thing like this -- var count=3; var pl=new Array(count);
I have an associative array which when var dumped looks like this: Array (

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.