Skip to content

hubgit/extract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

About

Extract is a template language that lets you declaratively transform HTML nodes into Javascript objects using JSON markup and CSS selectors. The idea is to write some JSON markup that looks like the object that you want to end up with, and then add selectors to tell Extract where the data should come from.

Usage

Turn:

<div id="test">
	<div class="example" id="example-1">
		<h2>Hello</h2>
	</div>
	<div class="example" id="example-2">
		<h2>Goodbye</h2>
	</div>
</div>

into:

[
	{ id: "1", message: "Hello" },
	{ id: "3", message: "Goodbye" }
]

using:

var template = [ '.example', { id: '@id', message: 'h2' } ];
var node = document.getElementById('test');
var result = Extract.parse(template, node);

Demonstration

Demo

History

Derived from Jath

License

MIT license

About

Extract data from HTML using a JSON template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published