@catlab/requirejs-plugins 0.0.0-stage → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.mdown ADDED
@@ -0,0 +1,148 @@
1
+ # RequireJS plugins
2
+
3
+ Small set of plugins for [RequireJS](http://requirejs.org). Some plugins may
4
+ also work on other AMD loaders (never tested it).
5
+
6
+ For more plugins check [RequireJS Wiki](https://github.com/jrburke/requirejs/wiki/Plugins).
7
+
8
+
9
+ ## Install
10
+
11
+ You can use [bower](http://bower.io/) to install it easily:
12
+
13
+ ```
14
+ bower install --save requirejs-plugins
15
+ ```
16
+
17
+
18
+
19
+ ## Plugins
20
+
21
+ - **async** : Useful for JSONP and asynchronous dependencies (e.g. Google Maps).
22
+ - **font** : Load web fonts using the [WebFont Loader API](https://code.google.com/apis/webfonts/docs/webfont_loader.html)
23
+ (requires `propertyParser`)
24
+ - **goog** : Load [Google APIs](http://code.google.com/apis/loader/)
25
+ asynchronously (requires `async!` plugin and `propertyParser`).
26
+ - **image** : Load image files as dependencies. Option to "cache bust".
27
+ - **json** : Load JSON files and parses the result. (Requires `text!` plugin).
28
+ - **mdown** : Load Markdown files and parses into HTML. (Requires `text!`
29
+ plugin and a markdown converter).
30
+ - **noext** : Load scripts without appending ".js" extension, useful for
31
+ dynamic scripts.
32
+
33
+ ### Other
34
+
35
+ - **propertyParser** : Just a helper used by some plugins to parse
36
+ arguments (not a real plugin).
37
+
38
+
39
+
40
+ ## Documentation
41
+
42
+ check the `examples` folder. All the info you probably need will be inside
43
+ comments or on the example code itself.
44
+
45
+
46
+
47
+ ## Basic usage
48
+
49
+ Put the plugins inside the `baseUrl` folder (usually same folder as the main.js
50
+ file) or create an alias to the plugin location:
51
+
52
+ ```js
53
+ require.config({
54
+ paths : {
55
+ //create alias to plugins (not needed if plugins are on the baseUrl)
56
+ async: 'lib/require/async',
57
+ font: 'lib/require/font',
58
+ goog: 'lib/require/goog',
59
+ image: 'lib/require/image',
60
+ json: 'lib/require/json',
61
+ noext: 'lib/require/noext',
62
+ mdown: 'lib/require/mdown',
63
+ propertyParser : 'lib/require/propertyParser',
64
+ markdownConverter : 'lib/Markdown.Converter'
65
+ }
66
+ });
67
+
68
+ //use plugins as if they were at baseUrl
69
+ define([
70
+ 'image!awsum.jpg',
71
+ 'json!data/foo.json',
72
+ 'noext!js/bar.php',
73
+ 'mdown!data/lorem_ipsum.md',
74
+ 'async!http://maps.google.com/maps/api/js?sensor=false',
75
+ 'goog!visualization,1,packages:[corechart,geochart]',
76
+ 'goog!search,1',
77
+ 'font!google,families:[Tangerine,Cantarell]'
78
+ ], function(awsum, foo, bar, loremIpsum){
79
+ //all dependencies are loaded (including gmaps and other google apis)
80
+ }
81
+ );
82
+ ```
83
+
84
+
85
+ ## Removing plugin code after build
86
+
87
+ [r.js](https://github.com/jrburke/r.js/blob/master/build/example.build.js)
88
+ nowadays have the `stubModules` setting which can be used to remove the whole
89
+ plugin code:
90
+
91
+ ```js
92
+ ({
93
+ // will remove whole source code of "json" and "text" plugins during build
94
+ // JSON/text files that are bundled during build will still work fine but
95
+ // you won't be able to load JSON/text files dynamically after build
96
+ stubModules : ['json', 'text']
97
+ })
98
+ ```
99
+
100
+
101
+ ## Notes about the Markdown plugin
102
+
103
+ The Markdown plugin was created mainly to be used to compile the markdown files
104
+ into HTML during the build step, if you set `pragmasOnSave.excludeMdown=true`
105
+ it will remove the `Markdown.Converter.js` and `mdown.js` files from the build.
106
+ Example build settings:
107
+
108
+ ```js
109
+ ({
110
+ baseUrl : './',
111
+ pragmasOnSave : {
112
+ excludeMdown : true
113
+ },
114
+ paths : {
115
+ mdown : 'lib/requirejs/mdown',
116
+ text : 'lib/requirejs/text',
117
+ markdownConverter : 'lib/Markdown.Converter'
118
+ },
119
+ modules : {
120
+ name : 'main'
121
+ }
122
+ })
123
+ ```
124
+
125
+ If `excludeMdown=true` you won't be able to load markdown files dynamically
126
+ after the build.
127
+
128
+
129
+
130
+ ## Writing your own plugins
131
+
132
+ Check [RequireJS documentation](http://requirejs.org/docs/plugins.html) for
133
+ a basic reference and use other plugins as reference. RequireJS official
134
+ plugins are a good source for learning.
135
+
136
+ Also be sure to check [RequireJS Wiki](https://github.com/jrburke/requirejs/wiki/Plugins).
137
+
138
+
139
+
140
+ ## Author
141
+
142
+ [Miller Medeiros](http://blog.millermedeiros.com/)
143
+
144
+
145
+
146
+ ## License
147
+
148
+ All the plugins are released under the MIT license.