diff --git a/README.md b/README.md index 04ec291..512f45a 100644 --- a/README.md +++ b/README.md @@ -27,21 +27,23 @@ file a bug. ## Usage - // create the morph object - var morph = Metamorph("HI!"); +```javascript +// create the morph object +var morph = Metamorph("HI!"); - // insert it into the DOM - $("#foo").html(morph.outerHTML()); +// insert it into the DOM +$("#foo").html(morph.outerHTML()); - // replace the contents - morph.html("BYE!"); +// replace the contents +morph.html("BYE!"); - // remove the morph - morph.remove(); +// remove the morph +morph.remove(); - // append the morph to an existing element, useful when - // manually creating morphs and not using a templating library - morph.appendTo(document.getElementById('foo')); +// append the morph to an existing element, useful when +// manually creating morphs and not using a templating library +morph.appendTo(document.getElementById('foo')); +``` ## Notes @@ -56,16 +58,18 @@ insert an `
`. This holds for the initial insertion as well as any updates. - var ul = $("
HI!
"); - ul.append(otherMorph.outerHTML()); // illegal +var otherMorph = Metamorph("HI!
"); +ul.append(otherMorph.outerHTML()); // illegal - morph.html("BYE!
") // illegal +morph.html("BYE!
") // illegal +``` ## Implementation @@ -104,7 +108,9 @@ the main initial API is `outerHTML`. If you like, you can disable the range API by using an environment variable: - MetamorphENV = { DISABLE_RANGE_API: true } +```javascript +MetamorphENV = { DISABLE_RANGE_API: true } +``` The current implementation of the range API in many browsers is slower than the alternative implementation inside Metamorph.js. It is a good