FCF - Full Stack Javascript Framework
OpenSource is a full stack development framework designed to simplify the development of WEB projects of various complexity levels.
It is based on unique technologies that open up new opportunities in development approaches with NODEJS.
Révision | ea8dd79c6e18d6cdc7de70dd37e088054c4051ea (tree) |
---|---|
l'heure | 2022-06-18 05:48:09 |
Auteur | Vladimir Markin <v.o.markin221@gmai...> |
Commiter | Vladimir Markin |
VERSION 1.1.45-a1 (hotfix: fixed crash with template arg if path not found)
@@ -699,111 +699,123 @@ | ||
699 | 699 | } |
700 | 700 | |
701 | 701 | this._processTemplateItem = async function(a_callIndex, a_argPath, a_template, a_inputArgs, a_taskInfo, a_cb) { |
702 | - let rootTemplateFile = a_taskInfo.template.split("+")[0]; | |
702 | + try { | |
703 | + let rootTemplateFile = a_taskInfo.template.split("+")[0]; | |
703 | 704 | |
704 | - let templatePath; | |
705 | - if (a_template.indexOf("+") == 0) | |
706 | - templatePath = rootTemplateFile + "+" + a_template.substr(1); | |
707 | - else | |
708 | - templatePath = a_template; | |
709 | - let templateFile = templatePath.split("+")[0]; | |
705 | + let templatePath; | |
706 | + if (a_template.indexOf("+") == 0) | |
707 | + templatePath = rootTemplateFile + "+" + a_template.substr(1); | |
708 | + else | |
709 | + templatePath = a_template; | |
710 | + let templateFile = templatePath.split("+")[0]; | |
710 | 711 | |
711 | - let block = a_template.split("+")[1]; | |
712 | - if (!block) | |
713 | - block = ""; | |
712 | + let block = a_template.split("+")[1]; | |
713 | + if (!block) | |
714 | + block = ""; | |
714 | 715 | |
715 | 716 | |
716 | - let fullPathRootTemplateFile = fcf.getPath(rootTemplateFile); | |
717 | - let fullPathTemplateFile = fcf.getPath(templateFile); | |
718 | - | |
719 | - inputArgs = fcf.append({}, a_inputArgs); | |
720 | - inputArgs.fcfParent = fcf.NRender.getParentId(a_taskInfo.args.fcfId, a_taskInfo._details.state); | |
721 | - | |
722 | - let templateInfo = await getTemplateInfo(a_template); | |
723 | - let existsWrapper = !("wrapper" in templateInfo.options) || !!templateInfo.options.wrapper; | |
724 | - let cp = `tmpl:${a_template}:${a_taskInfo.args.fcfId}:${a_argPath}:${a_callIndex}`; | |
725 | - helper.appendChildInfo(inputArgs, {fcfCP: cp}, a_taskInfo.args.fcfChildsArgs, existsWrapper); | |
726 | - inputArgs.fcfCP = cp; | |
727 | - | |
728 | - if (a_taskInfo.args.fcfInitialStorageOfChildren) | |
729 | - inputArgs.fcfInitialStorageOfChildren = true; | |
717 | + let fullPathRootTemplateFile = fcf.getPath(rootTemplateFile); | |
718 | + let fullPathTemplateFile = fcf.getPath(templateFile); | |
730 | 719 | |
731 | - fcf.application.render({ | |
732 | - template: templatePath, | |
733 | - theme: a_taskInfo._details.state.theme.getName(), | |
734 | - route: a_taskInfo.route, | |
735 | - state: a_taskInfo._details.state, | |
736 | - reqursion: true, | |
737 | - args: inputArgs, | |
738 | - secondary: true, | |
739 | - onResult: function(a_error, a_template) { | |
740 | - if (a_error) { | |
741 | - a_cb(a_error); | |
742 | - return; | |
720 | + inputArgs = fcf.append({}, a_inputArgs); | |
721 | + inputArgs.fcfParent = fcf.NRender.getParentId(a_taskInfo.args.fcfId, a_taskInfo._details.state); | |
722 | + | |
723 | + let templateInfo = await getTemplateInfo(a_template); | |
724 | + if (!templateInfo) | |
725 | + throw new fcf.Exception("ERROR_TEMPLATE_NOT_FOUND", {template: a_template}); | |
726 | + let existsWrapper = !("wrapper" in templateInfo.options) || !!templateInfo.options.wrapper; | |
727 | + let cp = `tmpl:${a_template}:${a_taskInfo.args.fcfId}:${a_argPath}:${a_callIndex}`; | |
728 | + helper.appendChildInfo(inputArgs, {fcfCP: cp}, a_taskInfo.args.fcfChildsArgs, existsWrapper); | |
729 | + inputArgs.fcfCP = cp; | |
730 | + | |
731 | + if (a_taskInfo.args.fcfInitialStorageOfChildren) | |
732 | + inputArgs.fcfInitialStorageOfChildren = true; | |
733 | + | |
734 | + fcf.application.render({ | |
735 | + template: templatePath, | |
736 | + theme: a_taskInfo._details.state.theme.getName(), | |
737 | + route: a_taskInfo.route, | |
738 | + state: a_taskInfo._details.state, | |
739 | + reqursion: true, | |
740 | + args: inputArgs, | |
741 | + secondary: true, | |
742 | + onResult: function(a_error, a_template) { | |
743 | + if (a_error) { | |
744 | + a_cb(a_error); | |
745 | + return; | |
746 | + } | |
747 | + a_cb(undefined, a_template.content); | |
743 | 748 | } |
744 | - a_cb(undefined, a_template.content); | |
745 | - } | |
746 | - }); | |
749 | + }); | |
750 | + } catch (e){ | |
751 | + a_cb(e); | |
752 | + } | |
747 | 753 | } |
748 | 754 | |
749 | 755 | |
750 | 756 | this._processView = async function(a_argPath, a_srcArg, a_taskInfo, a_cb) { |
751 | - let mode = a_srcArg.fcfMode ? a_srcArg.fcfMode : | |
752 | - a_taskInfo.args.fcfMode ? a_taskInfo.args.fcfMode : | |
753 | - "read"; | |
754 | - let view = fcf.buildView(a_srcArg.view, mode, a_taskInfo._details.state.theme); | |
755 | - let template = view.template; | |
756 | - let templateArgs = fcf.append({}, view); | |
757 | - fcf.append(templateArgs, a_srcArg.view.args); | |
758 | - templateArgs.record = a_srcArg.record; | |
759 | - templateArgs.fcfParent = fcf.NRender.getParentId(a_taskInfo.args.fcfId, a_taskInfo._details.state); | |
760 | - if (a_taskInfo.args.fcfMode) | |
761 | - templateArgs.fcfMode = a_taskInfo.args.fcfMode; | |
762 | - templateArgs.fcfAlias = view.alias; | |
763 | - templateArgs.fcfKey = a_taskInfo.args.fcfKey; | |
764 | - if (!templateArgs.fcfClass) | |
765 | - templateArgs.fcfClass = a_taskInfo.args.fcfChildClass; | |
766 | - templateArgs.fcfCP = "view:" + a_argPath; | |
767 | - templateArgs.value = fcf.isArg(view.value) | |
768 | - ? view.value : | |
769 | - !fcf.empty(view.value) | |
770 | - ? fcf.argVal(view.value) : | |
771 | - fcf.isArg(a_srcArg.value) | |
772 | - ? a_srcArg.value : | |
773 | - !fcf.empty(a_srcArg.value) | |
774 | - ? fcf.argVal(a_srcArg.value) : | |
775 | - fcf.isArg(view.default) | |
776 | - ? view.default : | |
777 | - !fcf.empty(view.default) | |
778 | - ? fcf.argVal(view.default) : | |
779 | - undefined; | |
780 | - if (a_taskInfo.args.fcfInitialStorageOfChildren) | |
781 | - templateArgs.fcfInitialStorageOfChildren = true; | |
757 | + try { | |
758 | + let mode = a_srcArg.fcfMode ? a_srcArg.fcfMode : | |
759 | + a_taskInfo.args.fcfMode ? a_taskInfo.args.fcfMode : | |
760 | + "read"; | |
761 | + let view = fcf.buildView(a_srcArg.view, mode, a_taskInfo._details.state.theme); | |
762 | + let template = view.template; | |
763 | + let templateArgs = fcf.append({}, view); | |
764 | + fcf.append(templateArgs, a_srcArg.view.args); | |
765 | + templateArgs.record = a_srcArg.record; | |
766 | + templateArgs.fcfParent = fcf.NRender.getParentId(a_taskInfo.args.fcfId, a_taskInfo._details.state); | |
767 | + if (a_taskInfo.args.fcfMode) | |
768 | + templateArgs.fcfMode = a_taskInfo.args.fcfMode; | |
769 | + templateArgs.fcfAlias = view.alias; | |
770 | + templateArgs.fcfKey = a_taskInfo.args.fcfKey; | |
771 | + if (!templateArgs.fcfClass) | |
772 | + templateArgs.fcfClass = a_taskInfo.args.fcfChildClass; | |
773 | + templateArgs.fcfCP = "view:" + a_argPath; | |
774 | + templateArgs.value = fcf.isArg(view.value) | |
775 | + ? view.value : | |
776 | + !fcf.empty(view.value) | |
777 | + ? fcf.argVal(view.value) : | |
778 | + fcf.isArg(a_srcArg.value) | |
779 | + ? a_srcArg.value : | |
780 | + !fcf.empty(a_srcArg.value) | |
781 | + ? fcf.argVal(a_srcArg.value) : | |
782 | + fcf.isArg(view.default) | |
783 | + ? view.default : | |
784 | + !fcf.empty(view.default) | |
785 | + ? fcf.argVal(view.default) : | |
786 | + undefined; | |
787 | + if (a_taskInfo.args.fcfInitialStorageOfChildren) | |
788 | + templateArgs.fcfInitialStorageOfChildren = true; | |
782 | 789 | |
783 | 790 | |
784 | - let templateInfo = await getTemplateInfo(template); | |
785 | - let block = template.split("+")[1]; | |
786 | - if (!block) | |
787 | - block = ""; | |
788 | - let existsWrapper = !("wrapper" in templateInfo.options) || !!templateInfo.options.wrapper; | |
789 | - helper.appendChildInfo(templateArgs, templateArgs, a_taskInfo.args.fcfChildsArgs, existsWrapper); | |
791 | + let templateInfo = await getTemplateInfo(template); | |
792 | + if (!templateInfo) | |
793 | + throw new fcf.Exception("ERROR_TEMPLATE_NOT_FOUND", {template: a_template}); | |
794 | + let block = template.split("+")[1]; | |
795 | + if (!block) | |
796 | + block = ""; | |
797 | + let existsWrapper = !("wrapper" in templateInfo.options) || !!templateInfo.options.wrapper; | |
798 | + helper.appendChildInfo(templateArgs, templateArgs, a_taskInfo.args.fcfChildsArgs, existsWrapper); | |
790 | 799 | |
791 | - fcf.application.render({ | |
792 | - template: template, | |
793 | - state: a_taskInfo._details.state, | |
794 | - theme: a_taskInfo._details.state.theme.getName(), | |
795 | - route: a_taskInfo.route, | |
796 | - args: templateArgs, | |
797 | - reqursion: true, | |
798 | - secondary: true, | |
799 | - onResult: function(a_error, a_template) { | |
800 | - if (a_error) { | |
801 | - a_cb(a_error); | |
802 | - return; | |
800 | + fcf.application.render({ | |
801 | + template: template, | |
802 | + state: a_taskInfo._details.state, | |
803 | + theme: a_taskInfo._details.state.theme.getName(), | |
804 | + route: a_taskInfo.route, | |
805 | + args: templateArgs, | |
806 | + reqursion: true, | |
807 | + secondary: true, | |
808 | + onResult: function(a_error, a_template) { | |
809 | + if (a_error) { | |
810 | + a_cb(a_error); | |
811 | + return; | |
812 | + } | |
813 | + a_cb(undefined, a_srcArg.fullResult ? a_template : a_template.content); | |
803 | 814 | } |
804 | - a_cb(undefined, a_srcArg.fullResult ? a_template : a_template.content); | |
805 | - } | |
806 | - }); | |
815 | + }); | |
816 | + } catch(e){ | |
817 | + a_cb(e); | |
818 | + } | |
807 | 819 | } |
808 | 820 | |
809 | 821 |
@@ -3461,6 +3461,7 @@ | ||
3461 | 3461 | fcf.addException("ERROR_REQUEST_PARAMETER_NOT_VALID", "Invalid request parameter format ${{1}}$"); |
3462 | 3462 | fcf.addException("ERROR_ASYNC_ACTIONS_CLOSED", "Adding a method to a completed execution queue"); |
3463 | 3463 | fcf.addException("ERROR_EVAL_TEMPL", "Execution error in the template ${{1}}$[${{2}}$:${{3}}$]"); |
3464 | +fcf.addException("ERROR_TEMPLATE_NOT_FOUND", "Template '@{{template}}@' not found"); | |
3464 | 3465 | fcf.addException("ERROR_EVAL_SCRIPT", "Execution error in the file ${{1}}$[${{2}}$]"); |
3465 | 3466 | fcf.addException("ERROR_INCORRECT_TEMPL_REQUEST_WRAPPER", "Wrapper request to an unavailable template ${{template}}$"); |
3466 | 3467 | fcf.addException("ERROR_NOSET_GET_ARG", "The required GET request parameter '${{arg}}$' was omitted"); |