Merge pull request #30 from CartoDB/support-multiple-values
Support multiple values/operands
This commit is contained in:
commit
decdcc5d46
@ -36,7 +36,9 @@ tree.Value.prototype = {
|
||||
v = "'" + v + "'";
|
||||
} else if (val.is === 'field') {
|
||||
// replace [variable] by ctx['variable']
|
||||
v = v.replace(/\[(.*)\]/g, "data['$1']");
|
||||
v = v.replace(/\[([^\]]*)\]/g, function(matched) {
|
||||
return matched.replace(/\[(.*)\]/g, "data['$1']");
|
||||
});
|
||||
}else if (val.is === 'call') {
|
||||
v = JSON.stringify({
|
||||
name: val.name,
|
||||
|
@ -183,6 +183,18 @@ describe('RenderingJS', function() {
|
||||
assert.equal(st.args[2].args[0].value, 10);
|
||||
});
|
||||
|
||||
it("should work with multiple operands", function(){
|
||||
var css = [
|
||||
'#layer {',
|
||||
' marker-width: [value] * [value] * 0.5;',
|
||||
'}'
|
||||
].join('\n');
|
||||
var shader = (new carto.RendererJS({ debug: false })).render(css);
|
||||
var layer = shader.getLayers()[0];
|
||||
var width = layer.shader['marker-width'].style({value: 4}, {zoom: 1});
|
||||
assert.equal(width, 8);
|
||||
});
|
||||
|
||||
it("should not throw `ReferenceError` with `=~` operator", function(){
|
||||
var css = [
|
||||
'#layer[name=~".*wadus*"] {',
|
||||
|
Loading…
Reference in New Issue
Block a user