Skip to content

Commit 2220891

Browse files
author
John Doherty
committed
added tranform explanation to the readme file
1 parent c0b42f8 commit 2220891

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.MD

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ $ npm install --save node-iframe-replacement
1515

1616
## Example usage
1717

18-
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 the view
18+
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+
20+
_I left the express logic out for readability, you can view the actual example [here](example/server.js)_
1921

2022
```js
2123
var iframeReplacement = require('node-iframe-replacement');
2224

23-
// replace res.render with iframe replacement version
25+
// add iframe replacement to express as middleware (adds res.merge method)
2426
app.use(iframeReplacement);
2527

2628
// create a regular express route
2729
app.get('/', function(req, res){
2830

29-
// respond to this request with our fake-new content embedded within the BBC News home page
31+
// respond to this request with our fake-news content embedded within the BBC News home page
3032
res.merge('fake-news', {
3133
sourceUrl: 'http://www.bbc.co.uk/news', // external url to fetch
3234
sourcePlaceholder: 'div[data-entityid="container-top-stories#1"]', // css selector to inject our content into
@@ -35,7 +37,7 @@ app.get('/', function(req, res){
3537
});
3638
```
3739

38-
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 or html attributes.
40+
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.
3941

4042
## fake-news html
4143

@@ -63,7 +65,7 @@ If you pass a function as the transform property ```transform: function($, model
6365

6466
## Auto base tag injection
6567

66-
To ensure the source scripts, styles and images load witin your site a base tag is automatically injected ```<base href="http://www.bbc.co.uk/news" />```.
68+
To ensure the source scripts, styles and images load within your site a base tag is automatically injected ```<base href="http://www.bbc.co.uk/news" />```.
6769

6870
Because of this, you need to ensure all the links within your conent are absolute.
6971

0 commit comments

Comments
 (0)