76 lines
1.5 KiB
JavaScript
76 lines
1.5 KiB
JavaScript
|
|
var VnObject = require ('./object');
|
|
|
|
/**
|
|
* Base class for compilers.
|
|
*/
|
|
module.exports = new Class
|
|
({
|
|
Extends: VnObject
|
|
|
|
,compile: function () {}
|
|
,postCompile: function () {}
|
|
,instantiate: function () {}
|
|
,preLink: function () {}
|
|
,link: function () {}
|
|
,connect: function () {}
|
|
,postLink: function () {}
|
|
,setProperty: function () {}
|
|
,free: function () {}
|
|
|
|
,initialize: function (builder)
|
|
{
|
|
this._builder = builder;
|
|
this._interpoler = builder._interpoler;
|
|
this.parent ();
|
|
}
|
|
|
|
/**
|
|
* Translates a string if it's a translatable string.
|
|
*
|
|
* @param {String} value The string to check and translate
|
|
* @return {String} The translated string or the same string if it is not translatable
|
|
*/
|
|
,translateValue: function (value)
|
|
{
|
|
switch (value.charAt (0))
|
|
{
|
|
case '_':
|
|
return _(value.substr (1));
|
|
case '\\':
|
|
switch (value.charAt(1))
|
|
{
|
|
case '_':
|
|
case '\\':
|
|
return value.substr (1);
|
|
default:
|
|
return value;
|
|
}
|
|
default:
|
|
return value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks if the passed attribute name it's an event.
|
|
*
|
|
* @param {String} attribute The attribute name
|
|
* @return {Boolean} %true if it's an event, otherwise %false
|
|
*/
|
|
,isEvent: function (attribute)
|
|
{
|
|
return /^on-\w+/.test (attribute);
|
|
}
|
|
|
|
/**
|
|
* Logs an error parsing the node.
|
|
*
|
|
* @param {String} error The error message template
|
|
* @param {...} varArgs The message template arguments
|
|
*/
|
|
,showError: function ()
|
|
{
|
|
this._builder.showError.apply (this._builder, arguments);
|
|
}
|
|
});
|