Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native designs: Replacing placeholders for "missing" assets #8769

Closed
anitaschiller opened this issue Aug 2, 2022 · 0 comments
Closed

Native designs: Replacing placeholders for "missing" assets #8769

anitaschiller opened this issue Aug 2, 2022 · 0 comments
Labels

Comments

@anitaschiller
Copy link

Type of issue

Question

Description

While testing the new native creative implementation (https://docs.prebid.org/prebid/native-implementation.html), we realized that a prebid native ##macro## only gets replaced if a corresponding asset is sent.

If the bidder e.g. doesn't send a value for body which would replace the ##hb_native_body## placeholder, the string ##hb_native_body## will be inserted in the HTML template.

I suppose that when the native template calls renderNativeAd(pbNativeTagData) (with pbNativeTagData.requestAllAssets set to true), the function below is responsible to answer that request?

Prebid.js/src/native.js

Lines 228 to 255 in f0596c4

export function getAllAssetsMessage(data, adObject) {
const message = {
message: 'assetResponse',
adId: data.adId,
assets: []
};
Object.keys(adObject.native).forEach(function(key, index) {
if (key === 'adTemplate' && adObject.native[key]) {
message.adTemplate = getAssetValue(adObject.native[key]);
} else if (key === 'rendererUrl' && adObject.native[key]) {
message.rendererUrl = getAssetValue(adObject.native[key]);
} else if (key === 'ext') {
Object.keys(adObject.native[key]).forEach(extKey => {
if (adObject.native[key][extKey]) {
const value = getAssetValue(adObject.native[key][extKey]);
message.assets.push({ key: extKey, value });
}
})
} else if (adObject.native[key] && CONSTANTS.NATIVE_KEYS.hasOwnProperty(key)) {
const value = getAssetValue(adObject.native[key]);
message.assets.push({ key, value });
}
});
return message;
}

That would mean that a key-value pair for body only gets pushed in the message.assets array if body is part of adObject.native. If it's not, the placeholder won't be replaced.

Question

So what exactly is the purpose of setting requestAllAssets to true? 😊 I'm sure there were a lot of thoughts behind this!

Wished behavior

We were hoping being able to use the :empty selector in our native design's CSS in order to set a HTML element to display: none in case the bidder didn't send a value that can be inserted instead of the placeholder. That - however - only works if the placeholder was replaced by an empty string.

Thank you for your help!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

3 participants