You can do something similar to the Ruby idiom, though without the `blank?` method:
str && !str.match(/^\s+$/) ? str : 'default'
You could also define blank as a helper function rather than a method:
function isBlank(val) {
return !val || val.match(/^\s+$/);
}
Things get simpler if you are not worried about whitespace-only strings because the empty string is falsy in JavaScript:
str ? str : 'default'
--
You received this message because you are subscribed to the Google Groups "Portland JavaScript Admirers" group.
To post to this group, send email to pd...@googlegroups.com.
To unsubscribe from this group, send email to pdxjs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pdxjs?hl=.
--
You received this message because you are subscribed to the Google Groups "Portland JavaScript Admirers" group.
To post to this group, send email to pd...@googlegroups.com.
To unsubscribe from this group, send email to pdxjs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pdxjs?hl=.
--
You received this message because you are subscribed to the Google Groups "Portland JavaScript Admirers" group.
To post to this group, send email to pd...@googlegroups.com.
To unsubscribe from this group, send email to pdxjs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pdxjs?hl=en.
In terms of browser support, you have to make sure you are serving pages with an XML mime type. I think the correct one is 'application/xml+xhtml'. It seems that most people are serving pages with an XHTML doctype but with 'text/html' as the mime type. So they are actually serving plain old HTML 4 or 5, depending on the browser, but do not realize it. I think this is part of why HTML 5 will be a return to "tag soup".
As I understand it HTML 5 will support an optional XML mode. But there won't be much reason to use it unless you are a purist. The XML mode won't add any particular features; and XML documents won't render in IE in general.
I have not read the spec. So I may be a little off in my understanding. I have mainly been reading others' summaries from the blogosphere. You might try looking up the HTML 5 Doctor for more information. And there are other resources out there.
On Dec 16, 2009 6:53 AM, "Bill Burcham" <bill.b...@gmail.com> wrote:
The W3C FAQ on the Future of XHTML from June, 2009 kind of makes it sound like as of June at least, their plan was that HTML 5 would be XML (have an "XML serialization" option).However, that FAQ cites Issue 41 "Decentralized Extensibility", which supports Mike's assessment (XML is out). In that note Sam Ruby asks for XML (and XML namespace) support for stuff like SVG, MathML (implying those foreign namespaces are currently incompatible with HTML 5).
-- You received this message because you are subscribed to the Google Groups "Portland JavaScript...
--
You received this message because you are subscribed to the Google Groups "Portland JavaScript Admirers" group.
To post to this group, send email to pd...@googlegroups.com.
To unsubscribe from this group, send email to pdxjs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pdxjs?hl=en.