|
@@ -483,22 +483,27 @@ 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 is_library_behaviour_implemented(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.
|
|
|
|
|
|
|
|
+is_library_behaviour_implemented(Mod) ->
|
|
|
|
+ lists:any(
|
|
|
|
+ fun({behaviour, BehavioursList}) ->
|
|
|
|
+ lists:member(erlydtl_library, BehavioursList);
|
|
|
|
+ (_) ->
|
|
|
|
+ false
|
|
|
|
+ end,
|
|
|
|
+ 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 +535,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))).
|
|
-
|
|
|