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

Portal doesn't render magic tags inside <script> tag #728

Open
cherifGsoul opened this issue Jan 27, 2020 · 6 comments
Open

Portal doesn't render magic tags inside <script> tag #728

cherifGsoul opened this issue Jan 27, 2020 · 6 comments

Comments

@cherifGsoul
Copy link
Member

cherifGsoul commented Jan 27, 2020

This was submitted in done-autorender by @MarcGodard

Not sure if this is related to donejs/autorender#160

I am also using the {{#portal (head)}}{{/portal}} in my head and the changes I am making are in the portal.

I am trying to add:

<script type="application/ld+json">{{seoSchema}}</script>

based on adding schema.org schema json to the head of my page. It is recommended to be in the head, but I also tried the body with the same results.

In SSR, when the variable includes the script tag, everything works, until SSR detaches (which the point of schema, this is fine as its only for SEO). If the script tag is in the stache file and the variable like the above, the variable doesn't get processed in either SSR or after it is detached. And actually completely disappears in the body.

Nothing changes in the head or the body when using data-keep from the first link in this issue other than it stays in the body.

I also tried without using portal, and same difference in the head tag.

The magic tags inside script tag are not rendered like is described.

@cherifGsoul cherifGsoul changed the title Portal doesn't render content magic tags inside <script> tag Portal doesn't render magic tags inside <script> tag Jan 27, 2020
@cherifGsoul
Copy link
Member Author

@MarcGodard
Copy link

@cherifGsoul Is it possible to add a type to it so it will process it?

@cherifGsoul
Copy link
Member Author

cherifGsoul commented Feb 4, 2020

@MarcGodard I don't think adding type will fix it, however after I discussed the issue with the team @bmomberger-bitovi pointed a good solution to make your use case working:

<script type="application/ld+json" innerHTML:from="seoSchema"></script>

This renders the property as expected and I checked it with portals in donejs example and it works fine, let us know if this works for you.

@MarcGodard
Copy link

@cherifGsoul Awesome, I will try that. Thanks @bmomberger-bitovi

@cherifGsoul
Copy link
Member Author

@MarcGodard did the suggested solution work for you?

@MarcGodard
Copy link

@cherifGsoul Actually, it did not, because I am using a helper function.

<script type="application/ld+json" innerHTML:from="l10n ('pageNewsSchema')"></script>

The helper is like a look up, looks up the variable with locales and gives that language version of it.

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

No branches or pull requests

2 participants