UNPKG

sbis3-node-ws

Version:

Модуль позволяет использовать ядро интерфейсного фреймворка sbis3-ws(`core.js`) и модуль работы с данными (`Source.js`) в приложении на nodejs.

52 lines (50 loc) 2.08 kB
define('js!Core/tmpl/js/astModules/else', ['js!Core/tmpl/js/helpers/processExpressions', 'js!Core/tmpl/js/helpers/errorHandling'], function elseLoader(processExpressions, errorHandling) { 'use strict'; var elseM = { module: function elseModule(tag, data) { tag.key = tag.prefix ? tag.prefix + '-' + tag.key : tag.key; function resolveStatement() { var source, elseSource, captureElse = false; if (tag.prev === undefined || (tag.prev.name !== 'ws:if' && tag.prev.name !== 'ws:else')) { errorHandling('There is no "if" for "else" module to use', this.filename); } try { source = tag.prev.attribs.data.data[0].value; } catch (err) { errorHandling('There is no data for "else" module to use', this.filename); } if (tag.attribs !== undefined) { try { elseSource = processExpressions(tag.attribs.data.data[0].name, data, this.calculators, this.filename); tag.attribs.data.data[0].value = elseSource; captureElse = true; } catch (err) { errorHandling('There is no data for "else" module to use for excluding place "elseif"', this.filename); } } if (captureElse) { if (!source) { if (elseSource) { if (tag.children !== undefined) { return this._process(tag.children, data, tag.key); } } } } else { if (!source) { if (tag.children !== undefined) { return this._process(tag.children, data, tag.key); } } } return; } return function elseModuleReturnable() { if (tag.children !== undefined) { return resolveStatement.call(this); } }; } }; return elseM; });