|
@@ -483,22 +483,21 @@ lib_module(Name, #dtl_context{ libraries=Libs }) ->
|
|
Mod = proplists:get_value(Name, Libs, Name),
|
|
Mod = proplists:get_value(Name, Libs, Name),
|
|
case code:ensure_loaded(Mod) of
|
|
case code:ensure_loaded(Mod) of
|
|
{module, Mod} ->
|
|
{module, Mod} ->
|
|
- IsLib = case proplists:get_value(behaviour, Mod:module_info(attributes)) of
|
|
|
|
- Behaviours when is_list(Behaviours) ->
|
|
|
|
- lists:member(erlydtl_library, Behaviours);
|
|
|
|
- _ -> false
|
|
|
|
- end,
|
|
|
|
- if IsLib ->
|
|
|
|
|
|
+ case implements_behaviour(erlydtl_library, Mod) of
|
|
|
|
+ true ->
|
|
case Mod:version() of
|
|
case Mod:version() of
|
|
?LIB_VERSION -> {ok, Mod};
|
|
?LIB_VERSION -> {ok, Mod};
|
|
V -> {load_library, Name, Mod, {version, V}}
|
|
V -> {load_library, Name, Mod, {version, V}}
|
|
end;
|
|
end;
|
|
- true -> {load_library, Name, Mod, behaviour}
|
|
|
|
|
|
+ false -> {load_library, Name, Mod, behaviour}
|
|
end;
|
|
end;
|
|
{error, Reason} ->
|
|
{error, Reason} ->
|
|
{load_library, Name, Mod, Reason}
|
|
{load_library, Name, Mod, Reason}
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
+implements_behaviour(Behaviour, Mod) ->
|
|
|
|
+ [] =:= [Behaviour] -- [B || [B] <- proplists:get_all_values(behaviour, Mod:module_info(attributes))].
|
|
|
|
+
|
|
read_library(Mod, Section, Which) ->
|
|
read_library(Mod, Section, Which) ->
|
|
[{Name, lib_function(Mod, Fun)}
|
|
[{Name, lib_function(Mod, Fun)}
|
|
|| {Name, Fun} <- read_inventory(Mod, Section),
|
|
|| {Name, Fun} <- read_inventory(Mod, Section),
|
|
@@ -530,4 +529,3 @@ remove_first_quote(String) ->
|
|
|
|
|
|
remove_last_quote(String) ->
|
|
remove_last_quote(String) ->
|
|
lists:reverse(remove_first_quote(lists:reverse(String))).
|
|
lists:reverse(remove_first_quote(lists:reverse(String))).
|
|
-
|
|
|