Skip to content

Commit 28b4c30

Browse files
committed
Remove slugToSiteName helper
1 parent b1aa90d commit 28b4c30

7 files changed

Lines changed: 1668 additions & 1721 deletions

File tree

README.md

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ app.set('view engine', 'handlebars');
4242

4343
# Helpers
4444

45-
Currently **56 helpers** in **10 categories**:
45+
Currently **55 helpers** in **10 categories**:
4646

4747

4848
### arrays
@@ -84,7 +84,6 @@ Currently **56 helpers** in **10 categories**:
8484
* [**extractImgWidth**](https://github.com/clay/handlebars#extractimgwidth--code--tests-) ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/extractImgWidth.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/extractImgWidth.test.js) )
8585
* [**indexOf**](https://github.com/clay/handlebars#indexof--code--tests-) ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/indexOf.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/indexOf.test.js) )
8686
* [**set**](https://github.com/clay/handlebars#set--code--tests-) ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/set.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/set.test.js) )
87-
* [**slugToSiteName**](https://github.com/clay/handlebars#slugtositename--code--tests-) ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/slugToSiteName.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/slugToSiteName.test.js) )
8887

8988
### numbers
9089

@@ -215,7 +214,7 @@ Add in article ads to list of components in an article
215214
#### Params
216215
* `content` _(array)_ the list of components in the article
217216
* `articleData` _(object)_ the entire article's data, used to pull in the different ad units defined
218-
* `afterComponent` _(string)_ the component type to insert the ad after
217+
* `afterCmp` _(string)_ the component type to insert the ad after
219218

220219
**Returns** _(object)_ splash
221220

@@ -572,22 +571,6 @@ set data into current context or other optional context/object<br /> _note:_ do
572571
//=> "abc"
573572
```
574573

575-
### slugToSiteName ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/slugToSiteName.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/slugToSiteName.test.js) )
576-
577-
return comma-separated site names from comma-separated slugs
578-
579-
#### Params
580-
* `slugs` _(string)_ comma-separated string of slugs
581-
582-
**Returns** _(string)_
583-
584-
#### Example
585-
586-
```hbs
587-
{{ slugToSiteName (commaSeparated crosspost) }}
588-
589-
```
590-
591574
## numbers
592575

593576

helpers/components/addInSplashAds.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,35 @@ function getComponentType(component) {
1515
* Add in article ads to list of components in an article
1616
* @param {array} content - the list of components in the article
1717
* @param {object} articleData - the entire article's data, used to pull in the different ad units defined
18-
* @param {string} afterComponent - the component type to insert the ad after
18+
* @param {string} afterCmp - the component type to insert the ad after
1919
* @return {object} splash
2020
*/
21-
module.exports = function (content, articleData, afterComponent) {
21+
module.exports = function (content, articleData, afterCmp) {
2222
var adUnits;
2323

2424
let newContent = []; // don't just replace the content (it's a sealed array), create a new array!
2525

2626
if (articleData) {
2727
adUnits = articleData.inSplashDesktopAd || articleData.inSplashTabletAd || articleData.inSplashMobileAd;
2828
}
29+
2930
if (adUnits) {
3031
_forEach(content, function (component) {
3132
const componentType = getComponentType(component);
3233

34+
3335
// add the current component before any ads
3436
newContent.push(component);
35-
if (componentType === afterComponent) {
37+
if (componentType === afterCmp) {
38+
/* istanbul ignore else */
3639
if (articleData.inSplashMobileAd) {
3740
newContent.push(articleData.inSplashMobileAd);
3841
}
42+
/* istanbul ignore else */
3943
if (articleData.inSplashTabletAd) {
4044
newContent.push(articleData.inSplashTabletAd);
4145
}
46+
/* istanbul ignore else */
4247
if (articleData.inSplashDesktopAd) {
4348
newContent.push(articleData.inSplashDesktopAd);
4449
}

helpers/components/addInSplashAds.test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,17 @@ describe(name, function () {
5252
});
5353

5454
it('returns the same content when the string passed in is not a component in the content', function () {
55-
var result = filter([paragraph4, paragraph1, mediaplayComponent, paragraph1], { inSplashDesktopAd: desktopAd, inSplashTabletAd: tabletAd, inSplashMobileAd: mobileAd }, 'notAComponent');
55+
var result = filter([desktopAd, paragraph1, mediaplayComponent, paragraph1], { inSplashDesktopAd: desktopAd, inSplashTabletAd: tabletAd, inSplashMobileAd: mobileAd }, 'notAComponent');
5656

57-
expect(result[0]).to.equal(paragraph4);
57+
expect(result[0]).to.equal(desktopAd);
5858
expect(result[1]).to.equal(paragraph1);
5959
expect(result[2]).to.equal(mediaplayComponent);
6060
expect(result[3]).to.equal(paragraph1);
6161
});
62+
63+
it('should just return the content if there is no articleData', function () {
64+
var result = filter([mobileAd, paragraph1, mediaplayComponent, paragraph1], {}, 'notAComponent');
65+
66+
expect(_.includes(result, mobileAd)).to.equal(true);
67+
});
6268
});

helpers/misc/slugToSiteName.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

helpers/misc/slugToSiteName.test.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)