Hướng dẫn json2html js

npm

2.2.2 • Public • Published 6 months ago

Show
  • Readme
  • Explore BETA
  • 0 Dependencies
  • 22 Dependents
  • 11 Versions

json2html

json2html is an open source javascript library that uses js templates to render JSON objects into HTML.

Build lightning fast, interactive client side templates using nothing but javascript.

Free to use under the MIT license.

www.json2html.com for full documentation.

Features

  • Native JS templates that work both the client and server
  • Interactive with embedded events directly in your templates
  • 100% Javascript so no need to learn any new syntax: use inline js functions for complex logic

Example

json2html.render(
    [
        {"name": "Justice League", "year":2021},
        {"name": "Coming 2 America", "year":2021}
    ], 
    {"<>": "li", "html":[
    	{"<>": "span", "text": "${name} (${year})"}
      ]});
    

Will render the following html

<li>
	<span>Justice League (2021)span>
li>
<li>
	<span>Coming 2 America (2021)span>
li

jQuery

Use seemlessly with jQuery, oh did we also mention that you can embed events in your template? Forget attaching your events after you've rendered your templates.

 {"<>":"button","text":"Click Me","onclick":(e)=>{
	alert("You just clicked this");
  }};		

Will render into the following html and will alert when clicked :)

<button>Click Mebutton>

Node.js

Use your temlpates seemlessly on Node.js

Installation

npm install node-json2html

Usage

	const json2html = require('node-json2html');
        
	let html = json2html.transform([{'male':'Bob','female':'Jane'},{'male':'Rick','female':'Ann'}],{"<>":"div","html":"${male} likes ${female}"});

TypeScript:

  import json2html from 'node-json2html'; //Import module
  const { render, component } = json2html; // Import methods from Json2html

www.json2html.com for full documentation.

Hướng dẫn json2html js

Hướng dẫn get user-agent nodejs

Thanks to decoder7283. Upvoted!I have added one more info to your solution:const app = express(); const useragent = require(express-useragent); app.use(useragent.express()); app.use(function(req, ...

Hướng dẫn hmac authentication nodejs

Hướng dẫn nodejs change working directory🏠 Go back to the homepageFind out how to serve an `index.html` HTML page using Node.js with no dependenciesI had this problem with a Node.js script I ...

Hướng dẫn khái niệm javascript

Trước khi vào bài viết của mình thì mình có 2 tình huống sau: Tình huống 1: Khi đi phỏng vấn Backend php, java,... hay bất kì ngôn ngữ nào họ sẽ hỏi bạn tùm ...

Setup javascript in visual studio code

Visual Studio Code includes built-in JavaScript IntelliSense, debugging, formatting, code navigation, refactorings, and many other advanced language features.Most of these features just work out of ...

Hướng dẫn initialize in javascript

JavaScript is a multi-paradigm, dynamic language with types and operators, standard built-in objects, and methods. Its syntax is based on the Java and C languages — many structures from those ...

Hướng dẫn convert json to html

excel apps conversionjson to html Đánh dấu ứng dụng này Nhấn Ctrl + D để thêm trang này vào mục yêu thích của bạn hoặc Esc để hủy hành động. Gửi liên kết ...

Hướng dẫn dùng learn JavaScript

Nội dung bài viếtVideo học lập trình mỗi ngàyKhông ai mong đợi điều này, nhưng JavaScript đã trở thành ngôn ngữ lập trình quan trọng nhất thế giới. - Douglas ...