Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add examples and documentation of `attribute` usage

  • Loading branch information...
commit d92319301ab926da16a1684031676481582d831a 1 parent 638ee10
@davidmurdoch davidmurdoch authored
View
32 Readme.md
@@ -13,7 +13,7 @@ This was made as an integrated feature of [Expressling][1].
# Usage
-Add the following to your `express` app (e.g. `server.js`):
+Add the following to your `express` app, e.g., `server.js`:
app.configure(function() {
app.set('public', __dirname + '/public');
@@ -36,11 +36,11 @@ For more options see <a href="#goodies">Goodies</a>.
Outputs HTML as shown below for development environment:
- <script type='text/javascript' src='/js/mylibs/script.js?v=$currentTimestamp'></script>
+ <script src='/js/mylibs/script.js?v=$currentTimestamp' type='text/javascript'></script>
-...and for production environment:
+&hellip; and for production environment:
- <script type='text/javascript' src='/js/mylibs/script.js'></script>
+ <script src='/js/mylibs/script.js' type='text/javascript'></script>
## Jade
@@ -48,11 +48,11 @@ Outputs HTML as shown below for development environment:
Outputs HTML as shown below for development environment:
- <link rel='stylesheet' href='/stylesheets/style.css?v=$currentTimestamp'>
+ <link href='/stylesheets/style.css?v=$currentTimestamp' rel='stylesheet'>
-...and for production environment:
+&hellip; and for production environment:
- <link rel='stylesheet' href='/stylesheets/style.css'>
+ <link href='/stylesheets/style.css' rel='stylesheet'>
# <a href="#goodies" name="goodies">Goodies</a>
@@ -64,13 +64,21 @@ Outputs HTML as shown below for development environment:
Outputs HTML as shown below for development environment:
- <link rel='stylesheet' href='/public/css/style.css?v=$currentTimestamp'>
- <link rel='stylesheet' href='/public/css/ie.css?v=$currentTimestamp'>
+ <link href='/stylesheets/style.css?v=$currentTimestamp' rel='stylesheet'>
+ <link href='/stylesheets/ie.css?v=$currentTimestamp' rel='stylesheet'>
-.. and for production environment:
+&hellip; and for production environment:
- <link rel='stylesheet' href='/public/css/style.css'>
- <link rel='stylesheet' href='/public/css/ie.css'>
+ <link href='/stylesheets/style.css' rel='stylesheet'>
+ <link href='/stylesheets/ie.css' rel='stylesheet'>
+
+### You can pass an object as the second parameter representing attributes and their values to add to the generated tag:
+
+ cacheBuster('/scripts/require.js', {'data-message': 'Hello world', 'data-main': '/app/main.js'})
+
+which outputs the following HTML:
+
+ <script data-main='/app/main.js' data-message='Hello world' src='/scripts/require.js' type='text/javascript'></script>
# Contributors
View
1  examples/public/index.jade
@@ -4,3 +4,4 @@ html
!= cacheBuster('/stylesheets/style.css')
body
p Hello world from jade
+ != cacheBuster('/scripts/script.js', {'data-message': 'Hello world from cacheBuster data attribute'})
View
7 examples/public/scripts/script.js
@@ -0,0 +1,7 @@
+(function(){
+ var scripts = document.getElementsByTagName('script')
+ , self = scripts[scripts.length - 1]
+ , message = self.getAttribute('data-message');
+
+ document.body.innerHTML += message;
+}());
View
4 examples/public/stylesheets/style.css
@@ -1,5 +1,7 @@
-/* line 1 : /home/atlantis/Public/express-cachebuster/examples/stylesheets/style.styl */
+/* line 1 : D:\Websites\express-cachebuster\node_modules\stylus\lib\functions\index.styl */
+
+/* line 1 : D:\Websites\express-cachebuster\examples\stylesheets\style.styl */
p {
color: #f00;
font-size: 24px;
Please sign in to comment.
Something went wrong with that request. Please try again.