[Ur] Data attributes

David Snider david at davidsnider.net
Sat May 10 17:05:59 EDT 2014


I think inlining bootstrap css classes into Ur Code might be a bad idea. 
A better approach would probably be to use semantic css class names and 
then use something like Less on the back-end to assign bootstrap classes 
to those names.

What do you think?

On 2014-02-25 00:14, Patrick Hurst wrote:
> Sergey Mironov <grrwlf at gmail.com> writes:
> 
>> What guarantees do we usually want when we use data-* ? Do we want to
>> be protected from repeating the same [data-foo] attribute twice?
> 
> This would be ideal; I don't remember what happens if you try to get 
> the
> value of a repeated attribute, but even if it's defined I wouldn't like
> to rely on it. The record method also has the advantage of avoiding
> pairs like ("foo bar", "baz") where the attribute name can't really be
> encoded. On the other hand, it's harder and Adam says it'd slow down
> type checking and has the possibility of making the types uglier.
> 
>> 
>> Are you working on writing a Bootstrap3 library? Do you have a public
>> repo to try?
>> 
>> Regards,
>> Sergey
> 
> I do; it's available at http://web.mit.edu/~phurst/hg/bootstrap/ . It
> doesn't have any support for the JavaScript stuff, just the CSS, and
> right now you have to do something like
> 
> rewrite style Bootstrap/* [-]
> 
> or
> 
> rewrite style Bootstrap3/* [-]
> 
> (although I'm planning on splitting it into two libraries per Adam's
> suggestion).
> 
> Patrick
> 
>> 
>> 2014-02-21 2:56 GMT+04:00 Patrick Hurst <phurst at mit.edu>:
>>> 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.
>>> 
>>> I e-mailed Adam about this and he suggested I take it to the list. 
>>> What
>>> do you all think?
>>> 
>>> _______________________________________________
>>> Ur mailing list
>>> Ur at impredicative.com
>>> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
>> 
>> _______________________________________________
>> Ur mailing list
>> Ur at impredicative.com
>> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
> 
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur



More information about the Ur mailing list