Skip to content

Commit

Permalink
Merge pull request #54 from cazwazacz/cazwazacz/webdev-848_unescape-s…
Browse files Browse the repository at this point in the history
…earch-results

[WEBDEV-848] Unescape search result data in component
  • Loading branch information
mattrayner committed Oct 17, 2018
2 parents 0cc2c84 + f7bac6b commit 25707cf
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pugin-components",
"version": "0.7.7",
"version": "0.7.8",
"description": "A shunter npm package containing dust components for beta.parliament.uk",
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="card">
<div class="card__details">
<h2><a href=some-url><b>Result</b> 1</a></h2>
<ul class="list--inline">
<li><span class="hint theme--grey-4 ">pdf</span></li>
<li><span class="url">some <b>shorter</b> url</span></li>
</ul>
<p>Some <b>text</b></p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "card__search__search-result",
"data": {
"heading-text": "<b>Result</b> 1",
"url": "some-url",
"hints": [
{
"name": "partials__hint",
"data": {
"display": {
"data": [
{
"component": "theme",
"variant": "grey-4",
"content": "pdf"
}
]
}
}
}
],
"short-url": "some <b>shorter</b> url",
"paragraph-content": "Some <b>text</b>"
}
}
6 changes: 6 additions & 0 deletions test/unit/components/card/search/search-result.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ describe('Search result card dust component', function() {
it('should return html from the dust component', function(done) {
testHelper.shunterTest('search-result', 'components__card__search__search-result', 'components/card/search', done)
});

context('unescaping html', function(done) {
it('should return html from the dust component', function(done) {
testHelper.shunterTest('html-tags-search-result', 'components__card__search__search-result', 'components/card/search', done)
});
});
});
6 changes: 3 additions & 3 deletions view/components/card/search/search-result.dust
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="card">
<div class="card__details">
<h2>
<a href={data.url}>{data.heading-text}</a>
<a href={data.url}>{data.heading-text|s}</a>
</h2>
<ul class="list--inline">

Expand All @@ -15,9 +15,9 @@
{/data.hints}
{/data.hints}
<li>
<span class="url">{data.short-url}</span>
<span class="url">{data.short-url|s}</span>
</li>
</ul>
<p>{data.paragraph-content}</p>
<p>{data.paragraph-content|s}</p>
</div>
</div>

0 comments on commit 25707cf

Please sign in to comment.