elements-lite
Advanced tools
Comparing version 0.1.18 to 0.2.1
@@ -5,4 +5,4 @@ | ||
/* | ||
* @version 0.1.18 | ||
* @date 2014-04-29 | ||
* @version 0.2.1 | ||
* @date 2014-05-15 | ||
* @stability 1 - Experimental | ||
@@ -9,0 +9,0 @@ * @author Lauri Rooden <lauri@rooden.ee> |
14
haml.js
@@ -5,4 +5,4 @@ | ||
/* | ||
* @version 0.1.18 | ||
* @date 2014-04-29 | ||
* @version 0.2.1 | ||
* @date 2014-05-15 | ||
* @author Lauri Rooden <lauri@rooden.ee> | ||
@@ -81,3 +81,2 @@ * @license MIT License | ||
return t.parent | ||
@@ -97,3 +96,2 @@ } | ||
return t.parent | ||
} | ||
@@ -143,5 +141,5 @@ }) | ||
var attrMap = { | ||
text: "textContent" in doc ? "textContent" : "innerText", | ||
html: "innerHTML", | ||
if: function(node, data, bind) { | ||
"text": "textContent" in doc ? "textContent" : "innerText", | ||
"html": "innerHTML", | ||
"if": function(node, data, bind) { | ||
console.log("if", arguments) | ||
@@ -152,3 +150,3 @@ var la = getLa(node) | ||
}, | ||
each: function(node, data, bind) { | ||
"each": function(node, data, bind) { | ||
var la = getLa(node) | ||
@@ -155,0 +153,0 @@ var arr = data && data[bind] |
{ | ||
"name": "elements-lite", | ||
"version": "0.1.18", | ||
"version": "0.2.1", | ||
"stability": 1, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -7,8 +7,6 @@ [1]: https://secure.travis-ci.org/litejs/elements-lite.png | ||
[8]: https://ci.testling.com/litejs/elements-lite | ||
[npm package]: https://npmjs.org/package/elements-lite | ||
[GitHub repo]: https://github.com/litejs/elements-lite | ||
@version 0.1.18 | ||
@date 2014-04-29 | ||
@version 0.2.1 | ||
@date 2014-05-15 | ||
@stability 1 - Experimental | ||
@@ -44,3 +42,77 @@ | ||
### Templates | ||
It is a template engine inspired by Haml and implemented with JavaScript for browser. | ||
#### Tags | ||
By default, text at the start of a line (or after only white space) represents an html tag. | ||
Indented tags are nested, creating the tree like structure of html. | ||
```html | ||
ul | ||
li Item A | ||
li Item B | ||
``` | ||
becomes | ||
```html | ||
<ul> | ||
<li>Item A</li> | ||
<li>Item B</li> | ||
</ul> | ||
``` | ||
From CSS Class selectors, ID selectors, Pseudo-classes selectors | ||
and Attribute selectors are supported. | ||
```html | ||
a#123.link.bold[href="#A"][title=go] link | ||
button:disabled | ||
``` | ||
becomes | ||
```html | ||
<a id="123" class="link bold" href="#A" title="go">link</a> | ||
<button disabled="disabled"></button> | ||
``` | ||
To save space you can use an inline syntax for nested tags. | ||
```html | ||
a>i text | ||
``` | ||
becomes | ||
```html | ||
<a><i>text</i></a> | ||
``` | ||
#### Inline templates | ||
```html | ||
ul.list | ||
:template my-row | ||
li.my-row > b row | ||
my-row | ||
my-row | ||
``` | ||
becomes | ||
```html | ||
<ul class="list"> | ||
<li class="my-row"><b>row</b></li> | ||
<li class="my-row"><b>row</b></li> | ||
</ul> | ||
``` | ||
Browser Support | ||
@@ -56,4 +128,4 @@ --------------- | ||
- [GitHub repo][] | ||
- [npm package][] | ||
- [Source-code on Github](https://github.com/litejs/elements-lite) | ||
- [Package on npm](https://npmjs.org/package/elements-lite) | ||
@@ -64,5 +136,5 @@ | ||
Copyright (c) 2012 Lauri Rooden <lauri@rooden.ee> | ||
Copyright (c) 2012, 2014 Lauri Rooden <lauri@rooden.ee> | ||
[The MIT License](http://lauri.rooden.ee/mit-license.txt) | ||
@@ -5,3 +5,3 @@ | ||
/* | ||
* @version 0.1.18 | ||
* @version 0.2.1 | ||
* @author Lauri Rooden <lauri@rooden.ee> | ||
@@ -8,0 +8,0 @@ * @license MIT License |
global.Event = global.Event || {} | ||
require("browser-upgrade-lite") | ||
require("functional-lite") | ||
require("../") | ||
require("../haml") | ||
@@ -186,2 +188,41 @@ function getString(node) { | ||
describe( "Haml" ). | ||
it ("supports haml"). | ||
equal(getString(El.haml("a\n b\n i")), '<a><b><i></i></b></a>'). | ||
equal(getString(El.haml("a \n b\n i")), '<a><b><i></i></b></a>'). | ||
equal(getString(El.haml("a\n b\n i link")), '<a><b><i>link</i></b></a>'). | ||
equal(getString(El.haml("a\n b \n i link")), '<a><b><i>link</i></b></a>'). | ||
equal(getString(El.haml("a\n b\n i link>to")), '<a><b><i>link>to</i></b></a>'). | ||
anyOf(getString(El.haml("a[href='#a>b']\n b.bold \n i#ital link")), | ||
[ '<a href="#a>b"><b class=bold><i id=ital>link</i></b></a>' | ||
, '<a href="#a>b"><b class="bold"><i id="ital">link</i></b></a>' | ||
, '<a href="#a>b"><b class="bold"><i id="ital">link</i></b></a>' | ||
, '<a href="#a%3Eb"><b class="bold"><i id="ital">link</i></b></a>' | ||
]). | ||
it ("supports block expansion"). | ||
equal(getString(El.haml("a>b>i")), '<a><b><i></i></b></a>'). | ||
equal(getString(El.haml("a > b>i")), '<a><b><i></i></b></a>'). | ||
equal(getString(El.haml("a>b>i link")), '<a><b><i>link</i></b></a>'). | ||
equal(getString(El.haml("a>b > i link")), '<a><b><i>link</i></b></a>'). | ||
equal(getString(El.haml("a>b>i link>to")), '<a><b><i>link>to</i></b></a>'). | ||
anyOf(getString(El.haml("a[href='#a>b']>b.bold > i#ital link")), | ||
[ '<a href="#a>b"><b class=bold><i id=ital>link</i></b></a>' | ||
, '<a href="#a>b"><b class="bold"><i id="ital">link</i></b></a>' | ||
, '<a href="#a>b"><b class="bold"><i id="ital">link</i></b></a>' | ||
, '<a href="#a%3Eb"><b class="bold"><i id="ital">link</i></b></a>' | ||
]). | ||
it ("supports templates"). | ||
anyOf(getString(El.haml(":template t1\n .temp1 t123\nt1")), | ||
[ '<div class=temp1>t123</div>' | ||
, '<div class="temp1">t123</div>' | ||
]). | ||
anyOf(getString(El.haml(":template t2\n .temp2>b t123\nt2")), | ||
[ '<div class=temp2><b>t123</b></div>' | ||
, '<div class="temp2"><b>t123</b></div>' | ||
]). | ||
anyOf(getString(El.haml(":template t3\n .temp3\n b t123\nt3")), | ||
[ '<div class=temp3><b>t123</b></div>' | ||
, '<div class="temp3"><b>t123</b></div>' | ||
]). | ||
done() | ||
@@ -188,0 +229,0 @@ |
var dom = require("dom-lite") | ||
require("functional-lite") | ||
@@ -4,0 +3,0 @@ global.document = dom.document |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72607
1620
137