[Ur] Data attributes

Adam Chlipala adamc at csail.mit.edu
Fri May 2 15:37:05 EDT 2014


I've just pushed an implementation of something close to the second 
suggestion below.  If using 'data-*' attributes literally within XML, 
with normal HTML5 syntax, then everything should just work as expected 
now.  For more information about encoding details, see the manual (in 
the working-version repository) and basis.urs.

On 02/20/2014 05:56 PM, Patrick Hurst wrote:
> Any attribute whose name starts with 'data-' is valid on any HTML5
> element with any value (see
> <http://www.w3.org/html/wg/drafts/html/CR/dom.html> section 3.5.9). Some
> frameworks, such as Twitter Bootstrap 3, rely on the presence of these,
> but right now there's no easy built-in way to include them using Ur/Web
> XML literals.
>
> One approach would be to add a 'data' pseudotag, similar to the 'link'
> tag on <a> elements, whose value is a record all of whose values are
> strings; [<div data={{Foo = "bar"}}/>] would then be rendered as [<div
> data-foo="bar"></div>]. The downside of this is that it'd involve
> significant changes to the standard library type system, since the [tag]
> type constructor would then need a new field for the names of all the
> data- attributes.
>
> Another approach is to have the value of the 'data' tag be a list of
> tuples of strings; [<div data={("foo", "bar") :: nil}/>] would then be
> rendered as [<div data-foo="bar"></div>]. I think this would be less
> safe, but also significantly easier to implement.



More information about the Ur mailing list