Closed adamcin closed 7 years ago
@adamcin, I fail to see the benefits of your proposal for the following reasons:
for the "Export Data Attributes as Use Options" use-case, this change might affect current implementations, if the data-*
attributes correspond to global script variables, by overriding them in the Use object's arguments' map;
the "Contextual Rewriting" feature, as defined here, could be better implemented through a custom-fitted use-object rather than through language specification changes, because such configuration specific value output would be made more clear to developers, rather than performing the rewrite through post-processing pipelines.
Dataset
data-sly-dataset
:String
->String
) hash table akin to HTML5 dataset, but excludes data-sly- attributes. For subsequentdata-sly-use
attributes defined on the same element, the entries of the hash table would be merged with any options specified in thedata-sly-use
attribute.dataset
identifier.The
data-sly-dataset
attribute would serve two functions.Export Data Attributes as Use Options
First, it would take advantage of native HTML syntax to provide an alternative to expression options for providing narrowly-scoped input arguments to the Use API.
For example:
Would be equivalent to:
Provide a Post-Process Hook for Contextual Rewriting
Second, it would provide a much narrower hook for a transformation stage than would a full-output SAX transformer to perform link rewriting or other similar environment- or context-sensitive function on attributes that are also used, by convention, to pass such contextual data to client-side scripts.
For example, a component may need to provide its client-side script the URL to a search results page, but this URL needs to be rewritten according to Sling Mapping rules:
A transformation pipeline can be configured to handle all start element SAX events, but this comes with a performance penalty on every page where this component appears and also introduces a config management challenge to keep the full list of every data attribute containing an href up to date.
Instead of using a SAX pipeline against the entire response, a more discrete transformation API can be defined that only deals with
Map<String, String>
as input and output, and that is triggered only after the data-sly-dataset attribute is evaluated on an element.Could then be transformed to:
I imagine there would be a couple constraints