HTML

HTML is The BEST JavaScript templating language EVER

  • 所有者: Marak/HTML
  • 平台:
  • 许可证:
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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: "bob@bob.com" }};

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">bob@bob.com</p>
</div>

Rendering an Array of Objects ( collection )

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

var users = [ 
  { name: "Bob", email: "bob@bob.com"}, 
  { name: "Marak", email: "marak@marak.com"}
];

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>bob@bob.com</p>
  </div>
  <div class="user">
    <p>Marak</p>
    <p>marak@marak.com</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.

概览

名称与所有者Marak/HTML
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证
发布数2
最新版本名称v0.2.0 (发布于 )
第一版名称v0.1.0 (发布于 )
创建于2012-08-19 11:04:01
推送于2013-06-03 23:34:52
最后一次提交2013-06-03 16:34:52
星数99
关注者数16
派生数64
提交数70
已启用问题?
问题数8
打开的问题数1
拉请求数3
打开的拉请求数0
关闭的拉请求数1
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?
去到顶部