Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/doughsay/fml

Functional Markup Language
https://github.com/doughsay/fml

Last synced: about 1 month ago
JSON representation

Functional Markup Language

Awesome Lists containing this project

README

        

FML: Functional Markup Language
===============================

FML is a functional representation of HTML or more generally, XML. It's meant
to be used in place of a templating engine, either client-side or server-side
using Node.js or anything supporting CommonJS modules.

Examples
--------

All tags have corresponding functions, and they all follow a similar pattern.

br()
// ->

div()
// ->

div("Hello, World!")
// ->

Hello, World!

divC("foo", "Bar!")
// ->

Bar!

divI("Foo", "Hello!")
// ->

Hello!

divA({'class': 'box', style: 'width: 100px;'}, "Hello again!")
// ->

Hello again!

In actuality, to output a string of HTML you need to pass the outputs of these
functions through fml.render(). The functions are easily composed, mapped,
passed around, whatever!

function person(p) {
return fml.liC('person',
fml.helpers.a(p.link, p.name)
);
}

function people(ps) {
return fml.ulI('People', ps.map(person));
}

var ps = [
{name: 'Chris', link: 'http://google.com'},
{name: 'John', link: 'http://example.com'}
];

var output = fml.render(people(ps));
/* ->


*/

More documentation to come!