|
|
|
@ -1,14 +1,18 @@
|
|
|
|
|
(function(tree) {
|
|
|
|
|
|
|
|
|
|
tree.Quoted = function Quoted(str, content) {
|
|
|
|
|
tree.Quoted = function Quoted(ever_quote, content) {
|
|
|
|
|
this.value = content || '';
|
|
|
|
|
this.quote = str.charAt(0);
|
|
|
|
|
// ever_quote is basicaly a shutoff switch for this quoted string
|
|
|
|
|
// being a real expression. you can pass `false` as the first parameter
|
|
|
|
|
// to make sure that this never gets double-quoted. This is used with fields.
|
|
|
|
|
this.ever_quote = ever_quote;
|
|
|
|
|
this.is = 'string';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tree.Quoted.prototype = {
|
|
|
|
|
toString: function(quotes) {
|
|
|
|
|
var xmlvalue = this.value.replace(/\'/g, ''');
|
|
|
|
|
return (quotes === true) ? "'" + xmlvalue + "'" : this.value;
|
|
|
|
|
return (this.ever_quote && quotes === true) ? "'" + xmlvalue + "'" : this.value;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'eval': function() {
|
|
|
|
@ -17,10 +21,10 @@ tree.Quoted.prototype = {
|
|
|
|
|
|
|
|
|
|
operate: function(op, other) {
|
|
|
|
|
if (other.is !== 'string') {
|
|
|
|
|
return new tree.Quoted(this.quote,
|
|
|
|
|
return new tree.Quoted(false,
|
|
|
|
|
this.toString(true) + op + other.toString());
|
|
|
|
|
} else {
|
|
|
|
|
return new tree.Quoted(this.quote,
|
|
|
|
|
return new tree.Quoted(true,
|
|
|
|
|
tree.operate(op, this.toString(), other.toString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|