Ecosyste.ms: Awesome

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

https://github.com/marianoguerra/emel

generate HTML (or XML) using CSS-like selectors in erlang
https://github.com/marianoguerra/emel

Last synced: 3 months ago
JSON representation

generate HTML (or XML) using CSS-like selectors in erlang

Lists

README

        

emel - generate HTML with CSS-like selectors
============================================

emel is an erlang module that allows to generate complex HTML (or XML) using
a syntax that is similar to CSS selectors.

emel is inspired by zen-coding: https://code.google.com/p/zen-coding/

get it
------

::

git clone https://github.com/marianoguerra/emel

build it
--------

::

cd emel
./rebar compile

test it
-------

::

./rebar eunit

use it
------

::

1> emel:gen("span[type=\"text\"]#asd.foo.bar.baz").
{ok,""}

2> {ok, S} = emel:gen("span[type=\"text\"]#asd.foo.bar.baz").
{ok,""}

3> io:format("~s~n", [S]).

ok

try it interactively
--------------------

run the following command::

erl -run emel shell -run init stop -noshell -pa ebin

play with an interactive console::

emel console Ctrl + d to exit

>>> p
{ok,[{node,1,p,[],[],[]}],[]}

>>> p{hi}
{ok,[{node,1,p,[],[],"hi"}],[]}

hi

>>> li*3
{ok,[{times,1,{node,1,li,[],[],[]},3}],[]}





  • author
    ------

    Mariano Guerra

    license
    -------

    BSD (+ optional beer to the author)

    examples
    --------

    input::

    p

    output::

    input::

    p#id

    output::

    input::

    p.class

    output::

    input::

    p#id.class

    output::

    input::

    p#foo.bar.baz

    output::

    input::

    p#id-$ * 3

    output::



    input::

    {hello}

    output::

    hello

    input::

    p{hello}

    output::

    hello

    input::

    h1#title.important {hi}

    output::

    hi

    input::

    ul > li * 3

    output::





    input::

    ul.list > li#item-$.list-item * 3

    output::





    input::

    .username > (span.first-name{Mariano} + { } + span.last-name{Guerra})

    output::


    Mariano Guerra

    input::

    p * 3 > a{asd}

    output::

    asd


    asd


    asd

    input::

    p > ({Click } + a{here} + { to continue})

    output::

    Click here to continue