hhvm / xhp-lib

Class libraries for XHP. XHP is a Hack feature that augments the syntax of the language such that XML document fragments become valid Hack expressions.
http://facebook.github.io/xhp-lib/
MIT License
1.38k stars 160 forks source link

Move HTML classes to namespace #219

Closed fredemmott closed 4 years ago

jjergus commented 4 years ago

Would this require adding a prefix everywhere?

use namespace XhpLib\HTML as h;
...
$link = <h:a href="...">...</h:a>;

Or would we expect people to do

use type XhpLib\HTML\a as a;
use type XhpLib\HTML\div as div;
...
fredemmott commented 4 years ago

Would this require adding a prefix everywhere?

Yep...

Or would we expect people to do

use type XhpLib\HTML\{a, div};

... or more likely, a separate library adding aliases/wrappers in the root namespace.

"HTML is not special" is an aspirational goal that can:

fredemmott commented 4 years ago

also, expecting most code in the future to be namespaced - so it'll already need to be <:a> instead of <a>; adding the NS isn't a much bigger usability change.

fredemmott commented 4 years ago

There's also arguments for it not to be special even if only used for frontend work:

jjergus commented 4 years ago

Makes sense, I agree not-special is better. Having valid HTML also be valid Hack code seemed like a nice property but probably doesn't really matter and might even be bad in some cases.

encouraging usage of safer wrappers, eg instead of

as long as they're not wrapping