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 6673211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:36:03+00:00 2026-05-26T03:36:03+00:00

I am building a news feed type feature which requires client-side rendering of feed

  • 0

I am building a news feed type feature which requires client-side rendering of feed items. There are different types of feed item which means each type requires a different template. I am currently using UnderscoreJS templating but am open to new ideas.

I am using a method roughly like this:

template : {
    f : "<li> <%= item.user.name %> uploaded a file </li>", // file upload
    m : "<li> <%= item.user.name %> just joined </li>", // just joined
    p : "<li> <%= item.user.name %> - <%= item.data.txt %> </li>" // comment
}

var html="";

for(i in feeditems){
    var item = feeditems[i];
    html+= _.template(template[item.type], { item: item });
}

$('#container').html(html);

Is this the best way to address this problem?

  • 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-05-26T03:36:04+00:00Added an answer on May 26, 2026 at 3:36 am

    From Underscore.js documentation

    template

    Compiles JavaScript templates into functions that can be evaluated for rendering. Useful for rendering complicated bits of HTML from JSON data sources.

    From what I read it should be very efficient.

    Is it the most efficient?

    Hard to say, the most efficient way would be to just hard code the string isn’t? No lookups at all, however, sometimes it’s better to sacrifice efficiency a bit to have more readable code.

    Do you have any performance problem? If you don’t, I wouldn’t worry. If you do, instead of thinking if this is the most efficient template, I’d profile the application, because most probably the bottleneck is elsewhere.

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

Sidebar

Related Questions

All, I'm building a site which will gather news stories from about 35 different
Building a client-side swing application what should be notified on a bus (application-wide message
I'm building a site that has three main types of online news publications: Article
I am building a News section for a client website (in ExpressionEngine) and they
I am developing a community / news article website where there is a side
I'm building a news feed. On initialization, the app calls Collection.fetch() and receives 20
I'm building a simple system like a realtime news feed, using node.js + socket.io.
I'm building a page with some news items on it. The current HTML I
I am building a news app for my website. I want to use a
I'm building a mini news CMS where the news added are sorted using a

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.