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

  • Home
  • SEARCH
  • 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 9148353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:14:56+00:00 2026-06-17T11:14:56+00:00

I am searching for something which renders an HTML template starting from a JSON

  • 0

I am searching for something which renders an HTML template starting from a JSON file of data.

The matter is that the plugin/framework/library I’m searching for must create itself the <html> template structure, starting from something very simple.

For example I have an simple html like this:

<ul>
  <li><li>
</ul>

and a json like this:

{
   "mylist":{
      "listone": 
          {"img" : "/img/pippo.gif" ,
           "text1" : "pluto",
           "text2" : "topolino",
           "link" : "http://www.sito.it"        
           },
      "listtwo":
          {"img" : "/img/pippo.gif" ,
           "text1" : "pluto",
           "text2" : "topolino",
           "link" : "http://www.sito.it"        
          }
   }
}

and I want the data to render in my document like this:

<ul>
  <li>
    <img src="/img/pippo.gif" />
    <h1>pluto</h1>
    <p><a href="http:://www.sito.it>topolino</a></p>
  </li>
</ul>

If I head already the entire structure I could use pure.js as usual, but, since I don’t have the inner tags in the li, can I inject the HTML code with the pure.js directives?
Or is it possible only with JsRender or similar?

  • 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-17T11:14:57+00:00Added an answer on June 17, 2026 at 11:14 am

    Pure JS allows you to use JavaScript function with directives. Whatever is returned from that function, will be used as a value for a directive.

    The argument of the function is an object with the following
    properties:

    • context : This is the full JSON that was passed for transformation
    • item* : the current loop item
    • items* : all the items of the loop
    • pos* : the current position in the loop. An integer when iterating an array, a property name iterating on a collection

    The following example shows how to do it.

    var data = {
      "img": "/img/pippo.gif",
        "text1": "pluto",
        "text2": "topolino",
        "link": "http://www.sito.it"
    }
    
    var directive = {
      'li': function (arg) {
        return "<img src=\""+arg.context.img+"\" /><h1>"
          +arg.context.text1+"</h1><p><a href=\""
          +arg.context.link+"\">"+arg.context.text2+"</a></p>"
      }
    }
    
    $('ul').render(data, directive);
    

    The given HTML:

    <ul><li></li></ul>
    

    Will become as following one (after rendering):

    <ul>
      <li>
        <img src="/img/pippo.gif">
        <h1>pluto</h1>
        <p>
          <a href="http://www.sito.it">topolino</a>
        </p>
      </li>
    </ul>
    

    I hope that will help.

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

Sidebar

Related Questions

Searching for a script, which can do show/hide functions without framework. Something like: <span
I'm searching a while for this and I can't found something that works for
I'm searching for something like the finished-signal from QDialog , only for QWidget .
in the recent past i’ve noticed quite often that, when searching something with google
I was searching google for something and saw the post that some one needed
I have been searching for something which might help me to resolve our current
I have tried searching through related answers but can't quite find something that is
I did some searching to try and generate jpg files from an html page
I was searching for something else related to template template parameters and happened upon
I'm searching a way to find implicit conversion. Something which give me the packages

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.