Skip to content

Commit c144742

Browse files
authored
Merge pull request #1109 from readthedocs/davidfischer/pass-headline-cta-to-ad-render
Pass headline/CTA to ad render
2 parents c39a8e7 + 8f985b3 commit c144742

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

adserver/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,6 +2355,11 @@ def render_ad(
23552355
# we want to display a simple placeholder image.
23562356
image_preview_url = static("image-placeholder.png")
23572357

2358+
# Render old style ads where HTML was allowed
2359+
# New style ads just use headline/content/CTA
2360+
text = self.render_links(click_url or self.link)
2361+
body = html.unescape(bleach.clean(text, tags=[], strip=True))
2362+
23582363
return template.render(
23592364
{
23602365
"ad": self,
@@ -2368,6 +2373,11 @@ def render_ad(
23682373
# to link the `Ads by EthicalAds` to.
23692374
"keywords": keywords,
23702375
"topics": topics,
2376+
# Pass headline, body, cta
2377+
# Newer ad formats can customize the display
2378+
"headline": self.headline,
2379+
"content": self.content or body,
2380+
"cta": self.cta,
23712381
}
23722382
).strip()
23732383

0 commit comments

Comments
 (0)