
* Replace tiny bitmaps with base64-encoded URIs
* Optimize SVGs; replace logo PNG with SVG
* Modernize favicon
* Embed CSS; a bit unorthodox, but we’re a single page so there’s no point in separate .css files and their separate HTTP requests
* Documentation is now markdown, converted to HTML on compilation
* Render the examples when we’re rendering index.html; they compile so quickly that there’s no need to pre-render them and save the intermediate .js files
* Split apart index.html into components that Cakefile assembles, so that we can add in logic to include different files for v1 versus v2
* Split building index.html and building test.html into two tasks; collapse the parts of `releaseHeader` into one compact function
* Move include logic into templates
* Get error messages tests to work in the browser
* Update output index.html
* Split body into nav and body
* Watch subtemplates
* Revert "Split body into nav and body"
This reverts commit ec9e559ec0
.
* Add marked
* Update gitignore
* Use idiomatic markdown output for code blocks (<pre><code>)
* Handle ids within the template, not in the Cakefile; remove marked’s auto-generated and conflicting ids
* Move the `codeFor` function into versioned folders, so that v1 and v2 docs can have different example code blocks/editors
* Update packages, including new highlight.js which supports our newer keywords and triple backticks (docs output is unchanged)
1.1 KiB
The Existential Operator
It’s a little difficult to check for the existence of a variable in JavaScript. if (variable) …
comes close, but fails for zero, the empty string, and false. CoffeeScript’s existential operator ?
returns true unless a variable is null or undefined, which makes it analogous to Ruby’s nil?
It can also be used for safer conditional assignment than ||=
provides, for cases where you may be handling numbers or strings.
codeFor('existence', 'footprints')
The accessor variant of the existential operator ?.
can be used to soak up null references in a chain of properties. Use it instead of the dot accessor .
in cases where the base value may be null or undefined. If all of the properties exist then you’ll get the expected result, if the chain is broken, undefined is returned instead of the TypeError that would be raised otherwise.
codeFor('soaks')
Soaking up nulls is similar to Ruby’s andand gem, and to the safe navigation operator in Groovy.