Skip to content
/ html Public

A RequireJS/AMD loader plugin for loading html fragments from plain text html files.

Notifications You must be signed in to change notification settings

gartz/html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

require-html

A RequireJS/AMD loader plugin for loading html fragments from plain text html files.

Known to work in RequireJS, but should work in other AMD loaders that support the same loader plugin API.

It requires text plugin from requirejs to work.

Install

npm install require-html

It can also be installed using volo:

volo add gartz/html

Usage

Use very like text plugin from requirejs, and it will return documentFragment

require(["html!some/module.html"],
    function(html) {
        console.log(html); // documentFragment
        document.body.appendChild(html);
        console.log(html); // empty documentFragment
        html.stash(); // documentFragment restored
        console.log(html.path) // some/module.html
        console.log(html.source) // source code from some/module.html
    }
);

License

Dual-licensed -- new BSD or MIT.

History

All template engines are reinventing the weel. DOM is powerfull enough to work with templates. For client you can use jquery or modern browser methods manipulate you documentFragment generated by the html.

For the server side is possible to use domjs.

Latest release

The latest release is always available from the "latest" tag.

About

A RequireJS/AMD loader plugin for loading html fragments from plain text html files.

Resources

Stars

Watchers

Forks

Packages