fixed cartocss with single quoted strings

This commit is contained in:
javi 2016-02-24 12:16:29 +01:00
parent fba91a0633
commit 0d2dddf978
2 changed files with 8 additions and 1 deletions

View File

@ -92,7 +92,7 @@ tree.Filterset.prototype.toJS = function(env) {
val = filter._val.toString(true); val = filter._val.toString(true);
} }
var attrs = "data"; var attrs = "data";
return attrs + "." + filter.key.value + " " + op + " " + (val.is === 'string' ? "'"+ val +"'" : val); return attrs + "." + filter.key.value + " " + op + " " + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val);
}).join(' && '); }).join(' && ');
}; };

View File

@ -129,7 +129,14 @@ describe('RenderingJS', function() {
shader = (new carto.RendererJS({ debug: true })).render(style); shader = (new carto.RendererJS({ debug: true })).render(style);
layer0 = shader.getLayers()[0]; layer0 = shader.getLayers()[0];
assert(layer0.isVariable()); assert(layer0.isVariable());
});
it("should parse styles with string", function() {
var style = '#test { [column = "test\'ing"] { marker-width: 10; } }';
var shader = (new carto.RendererJS({ debug: true })).render(style);
var layer = shader.getLayers()[0];
var props = layer.getStyle({column: 'test\'ing'}, { 'zoom': 0, 'frame-offset': 10 });
assert(props['marker-width'] === 10);
}); });
}); });