123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- -module(element_script).
- %%-author('Vladimir Galunshchikov').
- -include_lib("nitro/include/nitro.hrl").
- -export([
- render_element/1
- ]).
- render_element(Record) when Record#script.show_if == false -> [<<>>];
- render_element(Record) ->
- List = [
- %% global
- {<<"accesskey">>, Record#script.accesskey},
- {<<"class">>, Record#script.class},
- {<<"contenteditable">>,
- case Record#script.contenteditable of
- true -> "true";
- false -> "false";
- _ -> []
- end},
-
- {<<"contextmenu">>, Record#script.contextmenu},
- {<<"dir">>,
- case Record#script.dir of
- ltr -> "ltr";
- rtl -> "rtl";
- auto -> "auto";
- _ -> []
- end},
-
- {<<"draggable">>,
- case Record#script.draggable of
- true -> "true";
- false -> "false";
- _ -> []
- end},
-
- {<<"dropzone">>, Record#script.dropzone},
- {<<"hidden">>,
- case Record#script.hidden of
- true -> "hidden";
- _ -> []
- end},
-
- {<<"id">>, Record#script.id},
- {<<"lang">>, Record#script.lang},
- {<<"spellcheck">>,
- case Record#script.spellcheck of
- true -> "true";
- false -> "false";
- _ -> []
- end},
-
- {<<"style">>, Record#script.style},
- {<<"tabindex">>, Record#script.tabindex},
- {<<"title">>, Record#script.title},
- {<<"translate">>,
- case Record#script.contenteditable of
- true -> "yes";
- false -> "no";
- _ -> []
- end},
-
- %% spec
- {<<"async">>,
- case Record#script.async of
- true -> "async";
- _ -> []
- end},
-
- {<<"charset">>, Record#script.charset},
- {<<"defer">>,
- case Record#script.defer of
- true -> "defer";
- _ -> []
- end},
-
- {<<"src">>, Record#script.src},
- {<<"type">>, Record#script.type} | Record#script.data_fields
- ],
-
- wf_tags:emit_tag(<<"script">>,
- case Record#script.src of
- [] -> nitro:render(Record#script.body);
- _ -> []
- end, List).
|