Browse Source

unwrap ?CTX and ?REQ

221V 3 years ago
parent
commit
9f78bd2fea
3 changed files with 5 additions and 9 deletions
  1. 2 2
      include/n2z.hrl
  2. 0 4
      include/nitro.hrl
  3. 3 3
      src/render/wf_event.erl

+ 2 - 2
include/n2z.hrl

@@ -29,8 +29,8 @@
               from      = [] :: [] | binary(),
               vsn       = [] :: [] | binary() }).
 
--define(CTX(ClientId), n2z:cache(ClientId)).
--define(REQ(ClientId), (n2z:cache(ClientId))#cx.req).
+%-define(CTX(ClientId), n2z:cache(ClientId)).
+%-define(REQ(ClientId), (n2z:cache(ClientId))#cx.req).
 
 
 % Nitrogen Protocol

+ 0 - 4
include/nitro.hrl

@@ -1,10 +1,6 @@
 -ifndef(NITRO_HRL).
 -define(NITRO_HRL, true).
 
--ifndef(CTX).
--define(CTX, (erlang:get(context))).
--endif.
-
 -define(DEFAULT_BASE, {?ELEMENT_BASE([])}).
 -define(DEFAULT_BASE_TAG(Tag), {?ELEMENT_BASE([], Tag, [])}).
 -define(ELEMENT_BASE(Module), ?ELEMENT_BASE(Module, [], [])).

+ 3 - 3
src/render/wf_event.erl

@@ -7,9 +7,9 @@
 
 -export([target/1, new/2, new/6, new/7]).
 
-
 -record(ev, { module, msg, trigger, name }).
 
+
 target({ps, {qa, _Id}=T, Ps}) ->
   ["var t=", target(T), ";t.map(ts => '", nitro:js_escape(Ps), "'.split('.')"
      ".reduce((a, p)=>(a&&a[p]?a[p]:null), ts)).filter(o=>o)"];
@@ -34,8 +34,8 @@ new(P, E, D, N, Data, Source) -> new(P, E, D, N, Data, Source, <<>>).
 new([], _, _, _, _, _, _) -> <<>>;
 new(undefined, _, _, _, _, _, _) -> <<>>;
 new(Postback, Element, Delegate, Name, Data, Source, Validation) ->
-  %io:format("wf_event:new::: ~n~p~n~p~n", [Delegate, ?CTX]),
-  Module = nitro:coalesce([Delegate, ?CTX#cx.module]),
+  %io:format("wf_event:new::: ~n~p~n~p~n", [Delegate, erlang:get(context)]),
+  Module = nitro:coalesce([Delegate, (erlang:get(context))#cx.module]),
   
   Event = #ev{name=Name, module=Module, msg=Postback, trigger=Element},
   erlang:list_to_binary(["{ if(validateSources([",