com-lihaoyi / scalatags

ScalaTags is a small XML/HTML construction library for Scala.
https://com-lihaoyi.github.io/scalatags/
MIT License
758 stars 117 forks source link

Make StringFrag and Tag able to handle null value #101

Closed chungonn closed 8 years ago

chungonn commented 9 years ago

Below are the changes I made and hope you are agreeable to it.

cyberjar09 commented 9 years ago

👍

lihaoyi commented 8 years ago

I don't like making the project more "friendly" to nulls.

In general, I feel the number of times null sneaking into your template is a mistake far outweighs the number of times null sneaking into your template is intentional. For example, you almost never want to show your users null on your website, your CEO null on your analytics reports, or your prospective-employers null on your resume.

If that is true, then we should make null fail as early as possible, in a way the developer can debug it as easily as possible. That probably means making String => Frag, AttrValue[String], StyleValue[String], and all that check for nulls and blow up if they find one. There are a number of cases, not just the String => Frag case being changed in this diff.

Obviously the status quo, where a null sneaks in and blows up with an indecipherable stack trace, is sub-optimal. Although this PR makes it better, I don't think it's a step in the right direction.

japgolly commented 8 years ago

+1 Good call.