Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

Provide a way to escape special characters in field names #362

Closed
Tracked by #226
musicformellons opened this issue Sep 23, 2015 · 19 comments
Closed
Tracked by #226

Provide a way to escape special characters in field names #362

musicformellons opened this issue Sep 23, 2015 · 19 comments

Comments

@musicformellons
Copy link

In a good working stylesheet I replaced {name} with existing fieldname {name:fr} (and also tried quoting it in various ways) but it is not recognized. See also:
tilezen/vector-datasource#105 (comment)

@jfirebaugh
Copy link
Contributor

We've reserved various punctuation characters, including the colon, for potential future use, e.g. token defaults. Mapbox vector sources use an underscore instead, e.g. {name_fr}.

@musicformellons
Copy link
Author

ok, thx.

@nvkelso
Copy link

nvkelso commented Sep 23, 2015

@jfirebaugh Is there any plan to allow {"name:fr"} to access the property named "name:fr", while still preserving the token defaults?

Is there another existing technique to access a property besides the mustache syntax (like feature["name:fr"])?

@lucaswoj lucaswoj changed the title : seems not accepted within a field Provide a way to escape special characters in field names Nov 24, 2015
@lucaswoj
Copy link

What's the ideal syntax for escaping special characters in field names? Some ideas:

  • {"name:fr"}
  • {name\:fr}
  • {[name:fr]}

@musicformellons
Copy link
Author

@nvkelso Could provide a suggestion that would work for you?

@nvkelso
Copy link

nvkelso commented Nov 25, 2015

Either of these floats my boat (first one, quoted, is my preferred option):

  • {"name:fr"} - this seems most straight forward and SQL-like
  • {[name:fr]} - this is more like how Cascadenik used to do it, which is a nod to the past and optional.

This seems annoying:

  • {name\:fr}

@musicformellons
Copy link
Author

+1 for {"name:fr"}

@jfirebaugh
Copy link
Contributor

Rather than extending our text-substitution mini-language with defaults and escaping, I'd rather abandon the mini-language entirely in favor of built-in JSON syntax. Something like:

"icon-image": {
  "type": "substitution",
  "value": [{"ref": "maki"}, "-12"]
}

Where elements in the "value" array are either strings or objects with a "ref" property whose value names a feature property key. This value would have no reserved characters or escaping.

Evaluation would proceed by replacing refs with stringified feature property values, leaving strings as literals, and then concatenating the resulting array of strings.

This extends to support (recursive) defaults nicely:

"icon-image": {
  "type": "substitution",
  "value": [{"ref": "maki", "default": default}, "-12"]
}

where default can be another string literal or ref object.

I don't recall the exact syntax we decided on for data-driven functions but essentially "substitution" should be just another function type.

@lucaswoj
Copy link

lucaswoj commented Dec 4, 2015

cc @1ec5

@1ec5
Copy link
Contributor

1ec5 commented Dec 4, 2015

@jfirebaugh, your suggestion would be great, much better than a mini-language that will inevitably become as featureful and tricky to use as Bash variable operations. Would #104 (comment) require a different type, perhaps?

@lucaswoj
Copy link

lucaswoj commented Dec 4, 2015

@1ec5 We're open to syntax suggestions!

@nvkelso
Copy link

nvkelso commented Dec 11, 2015

+1

On Dec 4, 2015, at 11:02, Lucas Wojciechowski notifications@github.com wrote:

@1ec5 We're open to syntax suggestions!


Reply to this email directly or view it on GitHub.

@musicformellons
Copy link
Author

+1

@planemad
Copy link

This is a blocker to render localized maps in studio using the name:lang tags exported from OSM. One needs to manually rename the tags in the data currently.

@musicformellons
Copy link
Author

@lucaswoj Any news on this?

@sbma44
Copy link
Member

sbma44 commented Feb 16, 2016

this would also unlock some diagnostic mapping for the geocoder that relies on carmen properties which include colons

@lucaswoj
Copy link

@jfirebaugh @ansis Given that we don't want to go the route of a "mini-language" for token defaults, can we just lift the restrictions using colons in field names to unblock these use cases?

@jfirebaugh
Copy link
Contributor

Good point -- yes, I think we can (with the exception of { and }, of course).

@lucaswoj
Copy link

Closing in favor of #419

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants