Current section

Files

Jump to
diint_utilites_common_app src utilites html_render.erl
Raw

src/utilites/html_render.erl

%%%-------------------------------------------------------------------
%%% @author cheese
%%% @copyright (C) 2016, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 06. Jul 2016 1:43 PM
%%%-------------------------------------------------------------------
-module(html_render).
-author("cheese").
%% API
-export([render/1]).
%% API
-export([pr_render/2]).
render(Arr) ->
pr_render(Arr, <<>>).
pr_render([], Res) ->
Res;
pr_render([Head | Tail], Res) ->
Tag = case Head of
html_s ->
<<"<html>">>;
html_e ->
<<"</html>">>;
body_s ->
<<"<body>">>;
body_e ->
<<"<body>">>;
table_s ->
<<"<table style='border: 1px solid darkgray;background-color:#d0e9c6;opacity: 0.9;line-height:20px;padding:2px; width: 600px'>">>;
table_e ->
<<"</table">>;
th_s ->
<<"<tr style='background-color: darkseagreen;border: 1px solid black;font-weight:normal;padding:3px;height: 30px;'>">>;
th_e ->
<<"</tr>">>;
tr_s ->
<<"<tr>">>;
tr_e ->
<<"</tr>">>;
td_s ->
<<"<td>">>;
td_2_s ->
<<"<td colspan='2' style='text-align:center;'>">>;
td_e ->
<<"</td>">>;
row_break_2 ->
<<"<tr><td colspan='2' style='background-color:darkseagreen;padding:3px;line-height:1px;'>&nbsp;</td></tr>">>;
_ ->
Head
end,
pr_render(Tail, <<Res/binary, Tag/binary>>).