Skip to content

Commit

Permalink
!83 增加getTagAction方法返回null值实现
Browse files Browse the repository at this point in the history
Merge pull request !83 from dialYun/N/A
  • Loading branch information
entropy-cloud authored and gitee-org committed Aug 22, 2024
2 parents 08d9b8a + a3a59b2 commit cfd2daa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions nop-xlang/src/main/java/io/nop/xlang/api/XLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,24 @@ public static XplModel loadTpl(String path) {
return (XplModel) ResourceComponentManager.instance().loadComponentModel(path);
}

public static AbstractEvalAction getTagAction(String libPath, String tagName) {
public static AbstractEvalAction getTagAction(String libPath, String tagName, boolean isException) {
IXplTagLib lib = (IXplTagLib) ResourceComponentManager.instance().loadComponentModel(libPath);
IXplTag tag = lib.getTag(tagName);
if (tag == null)
throw new NopException(ERR_XLIB_UNKNOWN_TAG).param(ARG_LIB_PATH, libPath).param(ARG_TAG_NAME, tagName);
if (tag == null) {
if (isException) {
throw new NopException(ERR_XLIB_UNKNOWN_TAG).param(ARG_LIB_PATH, libPath).param(ARG_TAG_NAME, tagName);
}
return null;
}

IFunctionModel func = tag.getFunctionModel();
return new ExecutableFunctionEvalAction(func);
}

public static AbstractEvalAction getTagAction(String libPath, String tagName) {
return getTagAction(libPath, tagName, true);
}

public static IXplTag getTag(String libPath, String tagName) {
IXplTagLib lib = (IXplTagLib) ResourceComponentManager.instance().loadComponentModel(libPath);
IXplTag tag = lib.getTag(tagName);
Expand Down

0 comments on commit cfd2daa

Please sign in to comment.