<%~ %% @title erlyweb_html.et %% @doc This file contains functions for generating common HTML elements. %% You can import them into your templates or use them directly. %% %% @license for license information see LICENSE.txt -author("Yariv Sadan (yarivsblog@gmail.com, http://yarivsblog.com"). %% A helper function join(Args) -> join(Args, []). join([], Acc) -> []; join([Last], Acc) -> lists:reverse([Last | Acc]); join([First | Rest], Acc) -> join(Rest, [[First, $/] | Acc]). %> <%@ a(PathElems, Text) %><% Text %><%@ a(PathElems, Text, Props) %>>,Value,<<"\"">>] || {Name, Value} <- Props] %>><% Text %><%@ table(Records) %> <% table(Records, undefined) %> <%@ table(Records, Headers) %> <% headers(Headers) %> <% [row(R) || R <- Records] %>
<%@ headers(undefined) %> <%@ headers(Headers) %> <% [header(H) || H <- Headers] %> <%@ header(Data) %> <% Data %> <%@ row(Data) %> <% [cell(C) || C <- Data] %> <%@ cell(Data) %> <% Data %> <%@ form(Action, Function, Fields) %>
<% [field(F) || F <- Fields] %>
<%@ field({Name, Type, Modifier, Val} = Field) %> <% Name %><% input(Name, Type, Modifier, Val) %> <%@ input(Name) %><% input(Name, text_field, undefined, []) %> <%@ input(Name, text_area, _Modifier, Val) %> <%@ input(Name, text_field, undefined, Val) %> <%@ input(Name, text_field, MaxLength, Val) %> <%@ input(Name, select, Options, Val) %> <%@ option(Name, Name) %> <%@ option(Name, _Val) %> <%@ img(Src, Width, Height) %>