Skip to content

ryejs/rye.create

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rye.create

rye.create is a framework-agnostic zen-coding-like interface for creating DOM elements.

Usage

Just include rye.create.js in your page. It will export itself using requirejs/AMD, to a global $ variable or to window.create if $ is not defined.

Calls to create() return instances of DocumentFragment:

var fragment = $.create('section > p + div.places > li*5 > a[href=#$]')

Resulting in this DOM structure:

<section>
    <p></p>
    <div class="places">
        <li><a href="#1"></a></li>
        <li><a href="#2"></a></li>
        <li><a href="#3"></a></li>
        <li><a href="#4"></a></li>
        <li><a href="#5"></a></li>
    </div>
</section>

Calling fragment.toHTML() returns an HTML string representing it's contents.

Tests

  • node: run npm test (requires mocha-phantomjs)
  • browser: open rye.create/test/index.html in any browser

About

Zen-coding-like DOM element creation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published