Skip to content

Commit db77624

Browse files
committed
Adding syntax highlighting for remaining code blocks in the README.
1 parent 64eb7b7 commit db77624

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

README.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
88

99
Include script *after* the jQuery library (unless you are packaging scripts somehow else):
1010

11-
<script src="/path/to/jquery.cookie.js"></script>
11+
```html
12+
<script src="/path/to/jquery.cookie.js"></script>
13+
```
1214

1315
**Do not include the script directly from GitHub (http://raw.github.com/...).** The file is being served as text/plain and as such being blocked
1416
in Internet Explorer on Windows 7 for instance (because of the wrong MIME type). Bottom line: GitHub is not a CDN.
@@ -19,32 +21,44 @@ The plugin can also be loaded as AMD module.
1921

2022
Create session cookie:
2123

22-
$.cookie('the_cookie', 'the_value');
24+
```javascript
25+
$.cookie('the_cookie', 'the_value');
26+
```
2327

2428
Create expiring cookie, 7 days from then:
2529

26-
$.cookie('the_cookie', 'the_value', { expires: 7 });
30+
```javascript
31+
$.cookie('the_cookie', 'the_value', { expires: 7 });
32+
```
2733

2834
Create expiring cookie, valid across entire site:
2935

30-
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
36+
```javascript
37+
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
38+
```
3139

3240
Read cookie:
3341

34-
$.cookie('the_cookie'); // => "the_value"
35-
$.cookie('not_existing'); // => undefined
42+
```javascript
43+
$.cookie('the_cookie'); // => "the_value"
44+
$.cookie('not_existing'); // => undefined
45+
```
3646

3747
Read all available cookies:
3848

39-
$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
49+
```javascript
50+
$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
51+
```
4052

4153
Delete cookie:
4254

43-
// Returns true when cookie was found, false when no cookie was found...
44-
$.removeCookie('the_cookie');
55+
```javascript
56+
// Returns true when cookie was found, false when no cookie was found...
57+
$.removeCookie('the_cookie');
4558

46-
// Same path as when the cookie was written...
47-
$.removeCookie('the_cookie', { path: '/' });
59+
// Same path as when the cookie was written...
60+
$.removeCookie('the_cookie', { path: '/' });
61+
```
4862

4963
*Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.*
5064

@@ -54,13 +68,17 @@ Delete cookie:
5468

5569
By default the cookie value is encoded/decoded when writing/reading, using `encodeURIComponent`/`decodeURIComponent`. Bypass this by setting raw to true:
5670

57-
$.cookie.raw = true;
71+
```javascript
72+
$.cookie.raw = true;
73+
```
5874

5975
### json
6076

6177
Turn on automatic storage of JSON objects passed as the cookie value. Assumes `JSON.stringify` and `JSON.parse`:
6278

63-
$.cookie.json = true;
79+
```javascript
80+
$.cookie.json = true;
81+
```
6482

6583
## Cookie Options
6684

0 commit comments

Comments
 (0)