Skip to content

Commit

Permalink
Merge pull request #2 from unscriptable/master
Browse files Browse the repository at this point in the history
Update to latest bower specifications and show how to configure AMD loader
  • Loading branch information
Tyler Collard committed Dec 6, 2013
2 parents e4841b3 + 2168002 commit c572b1e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
40 changes: 27 additions & 13 deletions README.md
Expand Up @@ -15,26 +15,40 @@ or [Yeoman](http://yeoman.io/)

## Usage

The prettify script is AMD compatible and can be used modularly. Here is an example of it using RequireJS:
The prettify script is AMD compatible and can be used modularly. Here is an example of it in an AMD module:

```javascript
define(['jquery', 'prettify'], function($, prettify){
var code = null;
$('pre').addClass('prettyprint').each(function(idx, el){
code = el.firstChild;
code.innerHTML = prettify.prettyPrintOne(code.innerHTML);
})
);
});
define(['jquery', 'prettify'], function($, prettify){
var code = null;
$('pre').addClass('prettyprint').each(function(idx, el){
code = el.firstChild;
code.innerHTML = prettify.prettyPrintOne(code.innerHTML);
})
);
});
```

This version of google-code-prettify defines an anonymous module, which is more flexible. To allow your AMD loader to find google-code-prettify with a more convenient name, map a path to it as follows:

```js
// using RequireJS
require.config({
prettify: 'bower_components/google-code-prettify/prettify'
});

// using curl.js
curl.config({
prettify: 'bower_components/google-code-prettify/prettify'
});
```

Or it may just be used in a global context like the following:

```javascript
(function(){
$('pre').addClass('prettyprint');
prettyPrint();
})();
(function(){
$('pre').addClass('prettyprint');
prettyPrint();
})();
```

More information can be found in the original [README.html](http://google-code-prettify.googlecode.com/svn/trunk/README.html)
13 changes: 13 additions & 0 deletions bower.json
@@ -0,0 +1,13 @@
{
"name": "google-code-prettify",
"version": "1.0.1",
"main": "./src/prettify.js",
"dependencies": {},
"ignore": [
"closure-compiler",
"js-modules",
"tests",
"yui-compressor",
"Makefile"
]
}
6 changes: 0 additions & 6 deletions component.json

This file was deleted.

0 comments on commit c572b1e

Please sign in to comment.