diff --git a/src/erml_html5.erl b/src/erml_html5.erl
index f73e11f..a4db3ff 100644
--- a/src/erml_html5.erl
+++ b/src/erml_html5.erl
@@ -172,12 +172,7 @@ tag({include_raw, _Path, _LocalOpts}, Opts, State) ->
tag({include_template, Path}, #{ root := Root } = Opts, State) ->
case include_template(Path, Opts) of
{ok, Template} ->
- case compile(Template, Opts) of
- {ok, Content} ->
- {ok, Content, State};
- Elsewise ->
- Elsewise
- end;
+ tag(Template, Opts, State);
{error, Reason} ->
{stop, {error, Reason, filename:join(Root, Path)}, State}
end;
@@ -408,9 +403,14 @@ tag({Tag, Attributes, Content}, Opts, State)
% add support when a list is present. If a list is present, we assume
% this is a list of tags and we should treat them one by one.
%---------------------------------------------------------------------
-tag(Tags, Opts, State)
- when is_list(Tags) ->
- {stop, {todo, Tags, Opts}, State};
+tag(List, Opts, State)
+ when is_list(List) ->
+ case compile(List, Opts) of
+ {ok, Result} ->
+ {ok, Result, State};
+ Elsewise ->
+ Elsewise
+ end;
%---------------------------------------------------------------------
% All tags defined as atom, list or numbers are converted into binary
@@ -455,7 +455,7 @@ tag(Text, Opts, State)
% If unsupported tags are present, we should stop.
%---------------------------------------------------------------------
tag(Unsupported, Opts, State) ->
- {stop, {todo, Unsupported, Opts}, State}.
+ {stop, {todo, unsupported, Unsupported, Opts}, State}.
%%--------------------------------------------------------------------
%% internal function to deal with variable.
diff --git a/test/erml_SUITE.erl b/test/erml_SUITE.erl
index b4dff2d..11ed56c 100644
--- a/test/erml_SUITE.erl
+++ b/test/erml_SUITE.erl
@@ -121,88 +121,88 @@ tag() ->
%%--------------------------------------------------------------------
tag(_Config) ->
% empty document
- {ok, <<>>} = erml_tag:create([]),
- {ok, <<>>} = erml_tag:create(<<>>),
+ {ok, <<>>} = erml_html5:compile([]),
+ {ok, <<>>} = erml_html5:compile(<<>>),
% simple tag without attributes
- {ok, <<"">>} = erml_tag:create({html, []}),
- {ok, <<"">>} = erml_tag:create({<<"html">>, []}),
- {ok, <<"">>} = erml_tag:create({"html", []}),
+ {ok, <<"">>} = erml_html5:compile({html, []}),
+ {ok, <<"">>} = erml_html5:compile({<<"html">>, []}),
+ {ok, <<"">>} = erml_html5:compile({"html", []}),
{ok, <<"
">>}
- = erml_tag:create({html, {body, []}}),
+ = erml_html5:compile({html, {body, []}}),
% simple tag with attributes
- {ok, <<"">>} = erml_tag:create({html, #{}, []}),
- {ok, <<"">>} = erml_tag:create({<<"html">>, #{}, []}),
- {ok, <<"">>} = erml_tag:create({"html", #{}, []}),
+ {ok, <<"">>} = erml_html5:compile({html, #{}, []}),
+ {ok, <<"">>} = erml_html5:compile({<<"html">>, #{}, []}),
+ {ok, <<"">>} = erml_html5:compile({"html", #{}, []}),
{ok, <<"">>}
- = erml_tag:create({html, #{}, {body, #{}, []}}),
+ = erml_html5:compile({html, #{}, {body, #{}, []}}),
% simple tag with attributes support.
{ok, <<"">>}
- = erml_tag:create({html, #{}, {body, #{class => "test"}, []}}),
+ = erml_html5:compile({html, #{}, {body, #{class => "test"}, []}}),
{ok, <<"">>}
- = erml_tag:create({html, #{}, {body, #{class => test}, []}}),
+ = erml_html5:compile({html, #{}, {body, #{class => test}, []}}),
{ok, <<"">>}
- = erml_tag:create({html, #{}, {body, #{class => <<"test">>}, []}}),
+ = erml_html5:compile({html, #{}, {body, #{class => <<"test">>}, []}}),
% content and entities support
{ok, <<"test">>}
- = erml_tag:create({html, {body, <<"test">>}}),
+ = erml_html5:compile({html, {body, <<"test">>}}),
{ok, <<"test">>}
- = erml_tag:create({html, {body, test}}),
+ = erml_html5:compile({html, {body, test}}),
{ok, <<"123">>}
- = erml_tag:create({html, {body, 123}}),
+ = erml_html5:compile({html, {body, 123}}),
{ok, <<"1.00000000000000000000e+00">>}
- = erml_tag:create({html, {body, 1.0}}),
+ = erml_html5:compile({html, {body, 1.0}}),
{ok, <<"that's a test!
">>}
- = erml_tag:create([{html, {body, {p, [<<"that's a test!">>]}}}]),
+ = erml_html5:compile([{html, {body, {p, [<<"that's a test!">>]}}}]),
% dynamic template (gen_server call by default)
{ok, [ <<"">>
, {gen_server,call,server,paragraph,1000}
, <<"">>
]
- } = erml_tag:create({html, {body, {call, server, paragraph}}}),
+ } = erml_html5:compile({html, {body, {call, server, paragraph}}}),
% dynamic template (gen_server call)
{ok, [ <<"">>
, {gen_server,call,server,paragraph,1000}
, <<"">>
]
- } = erml_tag:create({html, {body, {gen_server, call, server, paragraph}}}),
+ } = erml_html5:compile({html, {body, {gen_server, call, server, paragraph}}}),
% dynamic template (gen_statem call)
{ok, [ <<"">>
, {gen_statem,call,server,paragraph,1000}
, <<"">>
]
- } = erml_tag:create({html, {body, {gen_statem, call, server, paragraph}}}),
+ } = erml_html5:compile({html, {body, {gen_statem, call, server, paragraph}}}),
% special tags
- {ok, <<"">>} = erml_tag:create({pre, []}),
- {ok, <<"test\ndata
">>}
- = erml_tag:create({pre, ["test", "data"]}),
- {ok, <<"test\ndata
">>}
- = erml_tag:create({pre, {code, ["test", "data"]}}),
+ % {ok, <<"">>} = erml_html5:compile({pre, []}),
+ % {ok, <<"test\ndata
">>}
+ % = erml_html5:compile({pre, ["test", "data"]}),
+ % {ok, <<"test\ndata
">>}
+ % = erml_html5:compile({pre, {code, ["test", "data"]}}),
% explicit content with some features
{ok, <<"test">>}
- = erml_tag:create({content, "test"}),
+ = erml_html5:compile({content, "test"}),
{ok, <<"test&">>}
- = erml_tag:create({content, "test&"}),
+ = erml_html5:compile({content, "test&"}),
{ok, <<"test'">>}
- = erml_tag:create({content, <<"test'">>}),
+ = erml_html5:compile({content, <<"test'">>}),
{ok,<<"test">>}
- = erml_tag:create({content, test}),
+ = erml_html5:compile({content, test}),
{ok,<<"test&">>}
- = erml_tag:create({content, <<"test&">>, #{entities => false}}),
+ = erml_html5:compile({content, <<"test&">>, #{entities => false}}),
% more complex case
{ok, <<"test"
"title
paragraph
"
"">>}
- = erml_tag:create({html, [{head, {title, test}}
+ = erml_html5:compile({html, [{head, {title, test}}
,{body, [{h1, title}
,{p, paragraph}
]}
@@ -217,56 +217,56 @@ tag(_Config) ->
custom_tag() -> [].
custom_tag(_Config) ->
% custom void element
- {ok, <<"">>} = erml_tag:create({{empty, html}, []}),
+ {ok, <<"">>} = erml_html5:compile({{empty, html}, []}),
% void elements support: area, base, br, col, embed, hr, img,
% input, link, meta, source, track, wbr
- {ok, <<"">>} = erml_tag:create({input, #{}}),
- {ok, <<"">>} = erml_tag:create({<<"input">>, #{}}),
- {ok, <<"">>} = erml_tag:create({"input", #{}}),
+ {ok, <<"">>} = erml_html5:compile({input, #{}}),
+ {ok, <<"">>} = erml_html5:compile({<<"input">>, #{}}),
+ {ok, <<"">>} = erml_html5:compile({"input", #{}}),
- {ok, <<"">>} = erml_tag:create({area, #{}}),
- {ok, <<"">>} = erml_tag:create({<<"area">>, #{}}),
- {ok, <<"">>} = erml_tag:create({"area", #{}}),
+ {ok, <<"">>} = erml_html5:compile({area, #{}}),
+ {ok, <<"">>} = erml_html5:compile({<<"area">>, #{}}),
+ {ok, <<"">>} = erml_html5:compile({"area", #{}}),
- {ok, <<"">>} = erml_tag:create({base, #{}}),
- {ok, <<"">>} = erml_tag:create({"base", #{}}),
- {ok, <<"">>} = erml_tag:create({<<"base">>, #{}}),
+ {ok, <<"">>} = erml_html5:compile({base, #{}}),
+ {ok, <<"">>} = erml_html5:compile({"base", #{}}),
+ {ok, <<"">>} = erml_html5:compile({<<"base">>, #{}}),
- {ok, <<"
">>} = erml_tag:create({br, #{}}),
- {ok, <<"
">>} = erml_tag:create({"br", #{}}),
- {ok, <<"
">>} = erml_tag:create({<<"br">>, #{}}),
+ {ok, <<"
">>} = erml_html5:compile({br, #{}}),
+ {ok, <<"
">>} = erml_html5:compile({"br", #{}}),
+ {ok, <<"
">>} = erml_html5:compile({<<"br">>, #{}}),
- {ok, <<"">>} = erml_tag:create({col, #{}}),
- {ok, <<"">>} = erml_tag:create({<<"col">>, #{}}),
- {ok, <<"">>} = erml_tag:create({"col", #{}}),
+ {ok, <<"">>} = erml_html5:compile({col, #{}}),
+ {ok, <<"">>} = erml_html5:compile({<<"col">>, #{}}),
+ {ok, <<"">>} = erml_html5:compile({"col", #{}}),
- {ok, <<"