Skip to content

Commit

Permalink
Merge pull request #30 from tbuchok/extension
Browse files Browse the repository at this point in the history
Extension
  • Loading branch information
tbuchok committed Jan 30, 2015
2 parents 2c0b812 + 89f27c7 commit cdf99a1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ var ad = vast.attachAd({
});
```

### Ad extensions

```javascript
var VAST = require('vast-xml');

var vast = new VAST();
var ad = vast.attachAd({
id : 1
, structure : 'inline'
, sequence : 99
, Error: 'http://error.err'
, Extensions: ['<xml>data</xml>'] // accepts an array or string of XML, warning: XML is not validated by this library!
, AdTitle : 'Common name of the ad'
, AdSystem : { name: 'Test Ad Server', version : '1.0' }
});
```

## Attach Impression tracking URLs

```javascript
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ var xml = function(options) {
if (r.adParameters) companion.element('AdParameters', r.adParameters.data, { xmlEncoded : r.adParameters.xmlEncoded });
});
});
if (ad.Extensions) {
var extensions = inline.element('Extensions');
[].concat(ad.Extensions).forEach(function(extension) {
extensions.element('Extension').raw(extension);
});
}
});
return response.end(options);
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vast-xml",
"version": "1.0.0",
"version": "1.2.0",
"description": "VAST XML responses for online video advertisers.",
"main": "index.js",
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions test/linear.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var ad = vast.attachAd({
, AdTitle : 'Common name of the ad'
, Error: 'http://error.err'
, AdSystem : { name: 'Test Ad Server', version : '1.0' }
, Extensions: ['<one><![CDATA[1]]></one>', '<two><dos id = "2" /></two>']
}).attachImpression({ id : 23, url : 'http://impression.com' });

test('`VAST` object', function(t){
Expand Down

0 comments on commit cdf99a1

Please sign in to comment.