Permalink
Browse files

Call load_tpl on startup automatically

Improvement suggested by Denis Ibaev
  • Loading branch information...
1 parent c9379ef commit c70cfe90fb5e878021b7e1378dafd04f7fb25c13 @goj goj committed Jul 1, 2010
Showing with 16 additions and 8 deletions.
  1. +8 −0 doc/NEXT_RELEASE
  2. +8 −8 lib/wpart-1.4.1/src/wpart_app.erl
View
8 doc/NEXT_RELEASE
@@ -0,0 +1,8 @@
+1.4.2
+=====
+
+ * wpart_my_primitive_type:load_tpl() is called automatically for
+ all user-defined primitive types on application startup.
+ - you don't have to do it yourself anymore
+ - make sure that you implement load_tpl
+ (it's required by wpart behaviour, anyway)
View
16 lib/wpart-1.4.1/src/wpart_app.erl
@@ -52,17 +52,17 @@ init([]) ->
%% Internal functions
%%====================================================================
--spec(ets_tables_install/0 :: () -> ok).
+-spec(ets_tables_install/0 :: () -> ok).
ets_tables_install() ->
{ok, [TypesT]} = file:consult(filename:join([code:priv_dir(wparts),"basic_types.conf"])),
- Types = tuple_to_list(TypesT),
- ets:insert(e_conf, {primitive_types, Types ++ e_conf:primitive_types()}),
-
+ Types = tuple_to_list(TypesT) ++ e_conf:primitive_types(),
+ ets:insert(e_conf, {primitive_types, Types}),
+
catch ets:delete(templates),
ets:new(templates, [named_table, public]),
-
+
Additional = [form, derived, input],
- lists:foreach(fun(Type) ->
+ lists:foreach(fun(Type) ->
Mod = list_to_atom("wpart_" ++ atom_to_list(Type)),
- Mod:load_tpl() end,
- Types ++ Additional).
+ Mod:load_tpl() end,
+ Types ++ Additional).

0 comments on commit c70cfe9

Please sign in to comment.