• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Marak/HTML: HTML is The BEST JavaScript templating language EVER

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

Marak/HTML

开源软件地址:

https://github.com/Marak/HTML

开源编程语言:

JavaScript 100.0%

开源软件介绍:

HTML is The BEST JavaScript templating language EVER

HTML was heavily inspired by Jade from Visionmedia

Features

  • HTML is valid (X) HTML 4.01 and HTML5!
  • HTML is Insanely Fast !
  • Safari, Internet Explorer, Chrome, and Firefox are all specifically optimized for rendering HTML!
  • HTML is highly portable ( Even tested it in Microsoft Frontpage and Macromedia Dreamweaver )
  • HTML is < 4 bytes in size!
  • It's not possible to write logic in HTML
  • I'm pretty annoyed I had to build this.

Note: I have no fucking clue how to successfully use Weld or Plates.

Core Concepts

  • You already know HTML
  • JSON data automatically maps to CSS classes
  • You cannot define any custom logic or maps with HTML
  • That's it.

Examples

Rendering basic data

var html = require('html-lang');
console.log(html.render({ name: "Bob" }, tmpl));
<p class="name">name placeholder</p>

outputs:

<p class="name">Bob</p>

Rendering an Object

var html = require('html-lang');

var user = { user: { name: "Bob", email: "[email protected]" }};

console.log(html.render(user, tmpl));
<div class="user">
  <p class="name">name placeholder</p>
  <p class="email">email placeholder</p>
</div>

outputs:

<div class="user">
  <p class="name">Bob</p>
  <p class="email">[email protected]</p>
</div>

Rendering an Array of Objects ( collection )

var html = require('html-lang');

var users = [ 
  { name: "Bob", email: "[email protected]"}, 
  { name: "Marak", email: "[email protected]"}
];

console.log(html.render(users, tmpl));
<div class="users">
  <div class="user">
    <p class="name">name placeholder</p>
    <p class="email">email placeholder</p>
  </div>
</div>

outputs:

<div class="users">
  <div class="user">
    <p>Bob</p>
    <p>[email protected]</p>
  </div>
  <div class="user">
    <p>Marak</p>
    <p>[email protected]</p>
  </div>
</div>

XML Node Attributes

<p class="name"><a href="" class="link"></a></p>
var html = require('html-lang');

var data = { 
  'link': "The big website", 
  'link.href': "http://big.vc" 
};

console.log(html.render(data, tmpl));

outputs:

<p class="name"><a href="http://big.vc" class="link">The big website</a></p>

That's it. I challenge you to find a use-case that isn't covered by HTML.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Sponsor @Marak on GitHub Sponsors · GitHub发布时间:2022-06-17
下一篇:
ironhack-labs/lab-html-exercise发布时间:2022-06-17
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap