Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elements-lite

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elements-lite

DOM buildel for browser

  • 0.10.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Weekly downloads
 
Created
Source
@version    0.10.0
@date       2016-01-28
@stability  1 - Experimental

Elements – Build Coverage

Syntax follows CSS Selectors where possible.

Usage

<script src=elements-lite.js></script> should place inside body.

Create elements one by one

El("div", "test").to(document.body)
//<div>test</div>

El("a#link[href='/home']", "Home").to(document.body)
//<a id="link" href="/home">Home</a>

El("a", {id:"link", href:"/home"}).append("Home").to(document.body)
//<a id="link" href="/home">Home</a>

El(".custom", "test").to(document.body)
//<div class="custom">test</div>

Templates

It is a template engine inspired by Haml but uses CSS selectors like syntax for describing elements and attributes.

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.

ul
  li Item A
  li Item B

becomes

<ul>
  <li>Item A</li>
  <li>Item B</li>
</ul>

From CSS Class selectors, ID selectors, Pseudo-classes selectors and Attribute selectors are supported.

a#123.link.bold[href="#A"][title=go] link
button:disabled

becomes

<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.

a>i text

becomes

<a><i>text</i></a>
Inline templates
ul.list
  @template my-row
    li.my-row > b row
  my-row
  my-row
  / Comment

becomes

<ul class="list">
  <li class="my-row"><b>row</b></li>
  <li class="my-row"><b>row</b></li>
</ul>
Data bindings
ul[data-bind="class: 'red', list.count > 5"]
  li[data-bind="txt: row"]

.. is equal to

ul &class: "red", list.count > 5
  li[data-bind="txt: row"]

Add custom bindings

El.bindings.enabled = function(enabled) {
    this.disabled = !enabled
}
ul &enabled: list.count > 5
  li[data-bind="txt: row"]

Browser Support

It should work IE6 and up but automated testing is currently broken.

Licence

Copyright (c) 2012-2015 Lauri Rooden <lauri@rooden.ee>
The MIT License

Keywords

FAQs

Package last updated on 01 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc