Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALOY-1700] Add support for <Script> tag in View XML files #937

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
29 changes: 29 additions & 0 deletions Alloy/commands/compile/parsers/Ti.UI.Script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var CU = require('../compilerUtils');
var U = require('../../../utils');
var fs = require('fs-extra');
var path = require('path');

exports.parse = function(node, state) {
var args = CU.getParserArgs(node, state);
var compilerConfig = CU.getCompilerConfig();
var code = '';

function getSourceCode(src) {
if ( src) {
const sourcePath = path.join(compilerConfig.dir.resourcesPlatform, src);
if (fs.existsSync(sourcePath)) {
return fs.readFileSync(sourcePath, 'utf8');
}
}
}

// get code from any external source
code += getSourceCode(args.createArgs.src) || '';

// get code from text node
code += U.XML.getNodeText(node) || '';

return {
code: code.trim() + '\n\n',
};
};