You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.MD
+15-9Lines changed: 15 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,13 @@ You can now argue that your web app can remain synced with the corperate website
13
13
$ npm install --save node-iframe-replacement
14
14
```
15
15
16
-
## Example usage
16
+
## Usage
17
+
18
+
### Example server
17
19
18
20
The example below will request the [BBC News](http://www.bbc.co.uk/news) home page and replace the contents of **div[data-entityid="container-top-stories#1"]** with the contents of our fake-news view:
19
21
20
-
_I left the express logic out for readability, you can view the actual example [here](example/server.js)_
22
+
_express logic excluded to improve readability, you can view the full example implementation[here](example/server.js)_
21
23
22
24
```js
23
25
var iframeReplacement =require('node-iframe-replacement');
// pass a function here to intercept the source html prior to merging
40
+
transform:null
36
41
});
37
42
});
38
43
```
39
44
40
45
If you pass a function as the transform property ```transform: function($, model) {}``` - the function will be called prior to rendering, allowing you to inject title tags, html attributes etc.
46
+
The `$` passed to your transform method is a JQuery like object using [cheerio](https://github.com/cheeriojs/cheerio#cheerio), removing the need to parse strings.
41
47
42
-
## fake-news html
48
+
### Example fake-news html
43
49
44
50
```html
45
51
<divstyle="margin: 00020px; overflow: auto;">
@@ -55,11 +61,11 @@ If you pass a function as the transform property ```transform: function($, model
55
61
</div>
56
62
```
57
63
58
-
##Input
64
+
### Example input
59
65
60
66

61
67
62
-
##Output
68
+
### Example output
63
69
64
70

65
71
@@ -73,7 +79,7 @@ Because of this, you need to ensure all the links within your conent are absolut
73
79
74
80
This project is a rethought, rebranded, relaunched version of my badly named [express-render-template](https://www.npmjs.com/package/express-render-template) module released in Arpil 2016.
0 commit comments