lib/Template.js
function attributesToJavascript(template, attr) {
	var i, name, value, js = [];
	for (i in attr) {
		if (attr.hasOwnProperty(i)) {

			// Translate
			name = Template.HTML_ATTRIBUTES[i] ? Template.HTML_ATTRIBUTES[i] : i;

			// Potentially interpolated attributes
			if (typeof attr[i] === 'string') {
				if (attr[i].length > 0) {
					js.push(JSON.stringify(name) + ':' + (ontext(template, attr[i], {virtual: false}).pop() || new VText).toJavascript());
				} else {
					js.push(JSON.stringify(name) + ':""');
				}
			} else {
				js.push(JSON.stringify(name) + ':' + JSON.stringify(attr[i]));
			}
		}
	}

	return '{' + js.join(',') + '}';
}
function attributesToJavascript(template, attr) {
	var i, name, value, js = [];
	for (i in attr) {
		if (attr.hasOwnProperty(i)) {

			// Translate
			name = Template.HTML_ATTRIBUTES[i] ? Template.HTML_ATTRIBUTES[i] : i;

			// Potentially interpolated attributes
			if (typeof attr[i] === 'string') {
				if (attr[i].length > 0) {
					js.push(JSON.stringify(name) + ':' + (ontext(template, attr[i], {virtual: false}).pop() || new VText).toJavascript());
				} else {
					js.push(JSON.stringify(name) + ':""');
				}
			} else {
				js.push(JSON.stringify(name) + ':' + JSON.stringify(attr[i]));
			}
		}
	}

	return '{' + js.join(',') + '}';
}
function attributesToJavascript ( template , attr ) { var i , name , value , js = [ ] ; for ( i in attr ) { if ( attr . hasOwnProperty ( i ) ) { // Translate name = Template . HTML_ATTRIBUTES [ i ] ? Template . HTML_ATTRIBUTES [ i ] : i ; // Potentially interpolated attributes if ( typeof attr [ i ] === 'string' ) { if ( attr [ i ] . length > 0 ) { js . push ( JSON . stringify ( name ) + ':' + ( ontext ( template , attr [ i ] , { virtual : false } ) . pop ( ) || new VText ) . toJavascript ( ) ) ; } else { js . push ( JSON . stringify ( name ) + ':""' ) ; } } else { js . push ( JSON . stringify ( name ) + ':' + JSON . stringify ( attr [ i ] ) ) ; } } } return '{' + js . join ( ',' ) + '}' ; }
Not particularly proud of this function.. obv it should probably be located in some kind of AttributeList class or something, but as it stands, the use of htmlparser2 requires a more 'aware' parser to do proper block parsing
Not particularly proud of this function .. obv it should probably be located in some kind of AttributeList class or something but as it stands the use of htmlparser2 requires a more aware parser to do proper block parsing